Hello! I build a simple bidirectional LSTM:
class LC_LSTM(nn.Module):
def __init__(self, nl):
super().__init__()
self.nl = nl
self.rnn = nn.LSTM(1, n_hidden, nl, bidirectional=True) #dropout=0.3,bidirectional=True)
self.l_out = nn.Linear(n_hidden*2, n_classes)
self.init_hidden(bs)
def forward(self, input):
outp,h = self.rnn(input.view(len(input), bs, -1), self.h)
return F.log_softmax(self.l_out(outp),dim=2)
def init_hidden(self, bs):
self.h = (V(torch.zeros(self.nl*2, bs, n_hidden)),
V(torch.zeros(self.nl*2, bs, n_hidden)))
And I want to pass some time series data to it. I wanted to apply it to one time series, before training, just to make sure it works, but I am getting only nan as outputs. The size of the time series is 3426 and bs=1. However, if I pass only a smaller part of the time series, say, the first 500 values, the code seems to work i.e. the output of the LSTM are actual numbers. Does it have to do with the fact that 3426 values passed at once is too much? Shouldn’t I get an out of memory error, instead of just nan’s? Thank you!