When I use lstm, there is always a problem about data dimension(input_size,out_size). Now train_x(batch_zize,time_step,input_szie),  train_y(batch_size,time_step,input_size).  Lstm forward(batch_first is True) code:
def forward(self,x):
x, (h_n, h_c) = self.rnn(x, None)
x = self.reg(x)
return x
Loss calculate code:
var_x = Variable(train_x)
var_y = Variable(train_y)
out = net1(var_x[start:end]).view(-1)
var_y=var_y[start:end].view(-1)
loss = criterion(out ,var_y)
Errors are about these two aspects.