Spaces:
Sleeping
Sleeping
Download model/module/module_ops.py from asdfasdfdsafdsa/pgps-demo: direct link, hf CLI and curl.
- Browser
- Download file 511 Bytes
-
https://huggingface.co/spaces/asdfasdfdsafdsa/pgps-demo/resolve/main/model/module/module_ops.py
- Command line
-
hf download hf://spaces/asdfasdfdsafdsa/pgps-demo/model/module/module_ops.py
-
curl -L -o module_ops.py https://huggingface.co/spaces/asdfasdfdsafdsa/pgps-demo/resolve/main/model/module/module_ops.py
511 Bytes
| import torch.nn as nn | |
| class GAP(nn.Module): | |
| """ | |
| Global Average pooling | |
| Widely used in ResNet, Inception, DenseNet, etc. | |
| """ | |
| def __init__(self): | |
| super(GAP, self).__init__() | |
| self.avgpool = nn.AdaptiveAvgPool2d((1, 1)) | |
| def forward(self, x): | |
| x = self.avgpool(x) | |
| # x = x.view(x.shape[0], -1) | |
| return x | |
| class Identity(nn.Module): | |
| def __init__(self): | |
| super(Identity, self).__init__() | |
| def forward(self, x): | |
| return x | |