Second order computations for nn.Upsample
- Dominant language
- Python
- Stars
- 617
- Forks
- 57
- PR merge metrics
- No merged PRs in 30d
Description
Hi
I need to compute the approximate hessian for a decoder network. The decoder consists of conv2d and upsample layers. Currently, backpack does not supports nn.Upsample. Since it is a non-parametric layer, it might not be too difficult to implement?
Here I define my model and a data point.
```
from backpack import backpack
from backpack.extensions import DiagGGNExact
model = torch.nn.Sequential(
torch.nn.Conv2d(1,8, kernel_size=3, padding=1),
torch.nn.MaxPool2d(2),
torch.nn.ReLU(),
torch.nn.Conv2d(8,8, kernel_size=3, padding=1),
torch.nn.Upsample(scale_factor=2, mode="nearest"),
torch.nn.ReLU(),
torch.nn.Conv2d(8,1, kernel_size=3, padding=1),
torch.nn.Flatten(),
)
lossfunc = torch.nn.MSELoss()
model = extend(model)
lossfunc = extend(lossfunc)
X = torch.zeros(1,1,8,8)
print(model(X).shape)
b = X.shape[0]
loss = lossfunc(model(X), X.view(b, -1))
with backpack(DiagGGNExact()):
loss.backward()
for param in model.parameters():
print(param.diag_ggn_exact)
```
will return this error
```
NotImplementedError: Extension saving to diag_ggn_exact does not have an extension for Module
```
Could you help implement this feature?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.