Hi,
I have been working to implement a simple one layer (Vainlla) RNN model using Pytorch. I am beginner in pytorch and I don’t know why my forward function is not working (my program is not calling forward method).
Would some one plz guide me or assist me to resolve this issue ? I shall be very thankful
Here is my implementation:
input_dimensions = 3
output_dimensions = 1
hidden_units = 5
x = Variable(torch.randn(1,input_dimensions))
y = Variable(torch.randn(1,output_dimensions))
hidden_init = Variable(torch.randn(1, hidden_units))
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.input_dimensions = input_dimensions
self.output_dimensions = output_dimensions
self.Wih = nn.Parameter(torch.Tensor(input_dimensions, hidden_units))
self.Uhh = nn. Parameter(torch.Tensor(hidden_units, hidden_units))
self.Wy = nn.Parameter(torch.Tensor(hidden_units, output_dimensions))
print('initialization has finished')
def forward(self, x):
print('forward')
W_ih = x.mm(self.Wih)
U_hh = hidden_init.mm(self.Uhh)
updated_hidden = W_ih + U_ih
output = updated_hidden.mm(self.Wy)
print('output', output)
return output
model = Net()
model.eval()
print(model)