I want to square the result of a maxpool layer. I tried the following:
class CNNClassifier(Classifier): # nn.Module def __init__(self, in_channels): super().__init__() self.save_hyperparameters('in_channels') self.cnn = nn.Sequential( # maxpool nn.MaxPool2d((1, 5), stride=(1, 5)), torch.square(), # layer1 nn.Conv2d(in_channels=in_channels, out_channels=32, kernel_size=5, ) Which to the experienced PyTorch user for sure makes no sense.
Indeed, the error is quite clear:
TypeError: square() missing 1 required positional arguments: "input"
How can I feed in to square the tensor from the preceding layer?