我已经构建了一个 LSTM 网络来对序列数据进行回归。当我尝试激活隐藏层(即 LSTM 层)时,它返回零。该网络只有一个隐藏层、一个输入层和一个输出层。
我尝试使用以下代码段获取隐藏层值。
print net.activate(data)
print net['in'].outputbuffer[net['in'].offset]
print net['hidden0'].outputbuffer[net['hidden0'].offset]
知道为什么吗?下面是更完整的代码片段
RopewayIn = RopewayOverallData[:-1, :]
RopewayOut = RopewayOverallData[1:, :]
ds.newSequence()
for i in range(noDataFrames):
ds.appendLinked( [RopewayIn[i,0],RopewayIn[i,1], RopewayIn[i,2], RopewayIn[i,3], RopewayIn[i,4], RopewayIn[i,5], RopewayIn[i,6], RopewayIn[i,7], RopewayIn[i,8], RopewayIn[i,9]],
[RopewayOut[i,0],RopewayOut[i,1], RopewayOut[i,2], RopewayOut[i,3], RopewayOut[i,4], RopewayOut[i,5], RopewayOut[i,6], RopewayOut[i,7], RopewayOut[i,8], RopewayOut[i,9]] )
net = buildNetwork(10,20,10, hiddenclass=LSTMLayer,outclass=LinearLayer, bias=True, recurrent=True)
trainer = RPropMinusTrainer(net, dataset=ds, verbose=True, weightdecay=0.01)
for i in range(10001):
trainer.trainEpochs(2)
print net.activate(RopewayOverallData[0,4])
print net['in'].outputbuffer[net['in'].offset]
print net['hidden0'].outputbuffer[net['hidden0'].offset