嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 20 元微信扫码支付:20 元
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
LSTM入门学习,正弦波序列预测
for i, input_t in enumerate(input.chunk(input.size(1), dim=1)):
h_t, c_t = self.lstm1(input_t, (h_t, c_t))
h_t2, c_t2 = self.lstm2(h_t, (h_t2, c_t2))
output = self.linear(h_t2) # output.shape:[batch,1]
outputs = [output] # outputs.shape:[[batch,1],...[batch,1]], list composed of n [batch,1],
for i in range(future): # if we should predict the future
h_t, c_t = self.lstm1(output, (h_t, c_t))
h_t2, c_t2 = self.lstm2(h_t, (h_t2, c_t2))
output = self.linear(h_t2) # output.shape:[batch,1]
outputs = [output] # outputs.shape:[[batch,1],...[batch,1]], list composed of n [batch,1],
outputs = torch.stack(outputs, 1).squeeze(2) # shape after stack:[batch, n, 1], shape after squeeze: [batch,n]
return outputs