class conv_try(nn.Module): def __init__(self): super(conv_try, self).__init__() # self.conv1 = nn.Conv1d(1, 32, kernel_size=3, stride=2, padding=1) # self.conv2 = nn.Conv2d(1, 32, kernel_size=3, stride=2, padding=1) self.encoder = nn.Sequential( nn.Conv1d(96, 192, kernel_size=3, stride=2, padding=1), nn.ReLU() ) def forward(self,x): x2 = self.encoder(x) return x2 if __name__ == '__main__': x =torch.rand(16,96,512) # print('x1:',x.size()) conv = conv_try(x)
Error Message:
Traceback (most recent call last):
File "C:/Users/12051/Desktop/vae+a/conv2.py", line 23, in <module>
conv = conv_try(x)
TypeError: __init__() takes 1 positional argument but 2 were given
Modified:
if __name__ == '__main__': x =torch.rand(16,96,512) # print('x1:',x.size()) conv = conv_try() ####Define a custom class a = conv(x) ##### and then call print(a.size())
Similar Posts:
- Solutions to errors encountered by Python
- [Solved] Pytoch nn.CrossEntropyLoss Error: RuntimeError: expected scalar type Long but found Float
- [Solved] pytorchImportError: numpy.core.multiarray failed to import
- Chinese character handwriting recognition based on densenetensorflow
- [design and development] Python learning notes – Super () argument 1 must be type, not classobj
- [Solved] torch.cuda.CudaError: CUDA driver version is insufficient for CUDA runtime version (35) [ WARN:0
- After installing torch on Linux, an error is still reported: importerror: no module named torch
- Python: __ new__ Method and the processing of typeerror: object() takes no parameters
- Python TypeError: __init__() missing 1 required positional argument: ‘on_delete’
- How to Solve Django xadmin installation Error [7 Types of Errors]