Hi I couldn’t grammatically quite understand the following example
m = nn.Conv1d(16, 33, 3, stride=2)
input = torch.randn(20, 16, 50)
output = m(input)
I think the type of nn.Conv1d is class, and accordingly m should be an instance of the class. Why in the third line, m(input) is used like a function?
Actually, it seems that >>> output = m(input) executes the function forward(self, input) defined in the class nn.Conv1d. So, to be grammatically correct, I think >>> output = m(input) should be changed into >>> output = m.forward(input) . But >>> output = m(input) indeed works.
Could anybody explain a bit about this? What grammatical rule does it follow?
The source code for Conv1d is at the following URL
Thank you very much!