-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Let v2.functional.gaussian_blur backprop through sigma parameter #8450
Copy link
Copy link
Closed
Description
the v1 version of gaussian_blur allows to backprop through sigma
(example taken from #8401)
import torch
from torchvision.transforms.functional import gaussian_blur
device = "cuda"
device = "cpu"
k = 15
s = torch.tensor(0.3 * ((5 - 1) * 0.5 - 1) + 0.8, requires_grad=True, device=device)
blurred = gaussian_blur(torch.randn(1, 3, 256, 256, device=device), k, [s])
blurred.mean().backward()
print(s.grad)
on CPU and on GPU (after #8426).
However, the v2 version fails with
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
The support in v1 is sort of undocumented and probably just works out of luck (sigma is typically expected to be a list of floats rather than a tensor). So while it works, it's not 100% clear to me whether this is a feature we absolutely want. I guess we can implement it if it doesn't make the code much more complex or slower.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels