Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more pooling layers to torch_nn.py #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion namedtensor/torch_nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,31 @@ def spec(self, dim_in, dims_conv, name_out):
return self


class AvgPool1d (_Update, nn.AvgPool1d):
pass


class AvgPool2d (_Update, nn.AvgPool2d):
pass


class AvgPool3d (_Update, nn.AvgPool3d):
pass


class MaxUnpool1d (_Update, nn.MaxUnpool1d):
pass


class MaxUnpool2d (_Update, nn.MaxUnpool2d):
pass


class MaxUnpool3d (_Update, nn.MaxUnpool3d):
pass



_update = [
"Linear",
"Conv1d",
Expand All @@ -151,6 +176,12 @@ def spec(self, dim_in, dims_conv, name_out):
"MaxPool1d",
"MaxPool2d",
"MaxPool3d",
"AvgPool1d",
"AvgPool2d",
"AvgPool3d",
"MaxUnpool1d",
"MaxUnpool2d",
"MaxUnpool3d",
]


Expand All @@ -161,7 +192,12 @@ def spec(self, dim_in, dims_conv, name_out):
MaxPool1d.__doc__ = nn.MaxPool1d.__doc__
MaxPool2d.__doc__ = nn.MaxPool2d.__doc__
MaxPool3d.__doc__ = nn.MaxPool3d.__doc__

AvgPool1d.__doc__ = nn.AvgPool1d.__doc__
AvgPool2d.__doc__ = nn.AvgPool2d.__doc__
AvgPool3d.__doc__ = nn.AvgPool3d.__doc__
MaxUnpool1d.__doc__ = nn.MaxUnpool1d.__doc__
MaxUnpool2d.__doc__ = nn.MaxUnpool2d.__doc__
MaxUnpool3d.__doc__ = nn.MaxUnpool3d.__doc__

class CrossEntropyLoss(_Loss, nn.CrossEntropyLoss):
def spec(self, dim_target):
Expand Down