Pytorch code is giving an error of missing position argument, while I have already given x as an input argument.
Code:
import torch.nn as nn
import torch.nn.functional as F
class Network(nn.Module):
def __init__(self):
super().__init__()
self.hidden = nn.Linear(8, 5)
self.output = nn.Linear(5, 1)
def forward(self, x):
x = 2*F.sigmoid(self.hidden(x))
x = F.softmax(self.output(x), dim= 0)
return x
x = torch.tensor([1.0, 2.0, 3.0, 4.0,5.0,6.0,7.0,8.0] , dtype = torch.float32)
f = Network()
print(f(x))
tensor([1.], grad_fn=)
Network.forward(x)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Input In [98], in <cell line: 1>() ----> 1 Network.forward(x)
TypeError: forward() missing 1 required positional argument: 'x'