GaussianBlur¶ class torchvision.transforms.GaussianBlur(kernel_size, sigma=(0.1, 2.0))[源]¶ 使用随机选择的高斯模糊来模糊图像。如果图像是 torch Tensor,则期望其形状为 [..., C, H, W],其中 ... 最多表示一个前导维度。 参数: kernel_size (int 或 sequence) – 高斯核的大小。 sigma (float 或 tuple of python:float (min, max)) – 用于创建模糊核的标准差。如果为 float,则 sigma 是固定的。如果为 float 的元组 (min, max),则 sigma 会在给定的范围内均匀随机选择。 返回: 输入图像的高斯模糊版本。 返回类型: PIL 图像或张量 使用 GaussianBlur 的示例 转换图示 转换图示 forward(img: Tensor) → Tensor[源]¶ 参数: img (PIL Image 或 Tensor) – 要模糊的图像。 返回: 高斯模糊后的图像 返回类型: PIL 图像或张量 static get_params(sigma_min: float, sigma_max: float) → float[源]¶ 为随机高斯模糊选择 sigma。 参数: sigma_min (float) – 可为模糊核选择的最小标准差。 sigma_max (float) – 可为模糊核选择的最大标准差。 返回: 用于计算高斯模糊核的标准差。 返回类型: 浮点数