Im new to RNNs (pretty new to ANN in general and im trying to train a network to predict stock market direction next day as a school project (impossible I know :P)

So far I have a network that trains but only predicts 0’s (1 for upward movement and 0 for down)

I want to add a tanh layer, but I get an error message for shape mismatch. can anyone help?

class SimpleRNN(nn.Module):

def **init**(self, hidden_size):

super(SimpleRNN, self).**init**()

self.hidden_size = hidden_size

```
self.inp = nn.Linear(21, hidden_size)
self.rnn = nn.LSTM(hidden_size, hidden_size, 2, dropout=0.05, batch_first=True)
self.act = nn.Tanh()
self.out = nn.Linear(hidden_size, 1)
self.softmax = nn.LogSoftmax(dim=1)
def step(self, input, hidden=None):
input = self.inp(input.view(1, -1)).unsqueeze(1)
output, hidden = self.rnn(input, hidden)
output = self.act(self.out(output[0]))
output = self.out(output.squeeze(1))
output = self.softmax(output)
return output, hidden
def forward(self, inputs, hidden=None, force=True, steps=0):
if force or steps == 0: steps = len(inputs)
outputs = Variable(torch.zeros(steps, 1, 1))
for i in range(steps):
if force or i == 0:
input = inputs[i]
else:
input = output
output, hidden = self.step(input, hidden)
outputs[i] = output
return outputs, hidden
```