我现在可以使用 Chainer 创建和教授单层 rnn-s,但是当我尝试扩展我的网络时遇到了错误。这是我的代码,我注释掉了 2. 隐藏层部分,所以这应该作为单层网络运行
#Regression
class Regression(Chain):
def __init__(self, predictor):
super(Regression, self).__init__(predictor=predictor)
def __call__(self, x, t):
y = self.predictor(x)
loss = F.mean_squared_error(y, t)
report({'loss': loss}, self)
return loss
#return loss
#%%
#RNN
class RNN(Chain):
def __init__(self):
super(RNN, self).__init__(
lstm=L.LSTM(12, 50), #
# lstm2=L.LSTM(100, 100),
out=L.Linear(50, 1), #
)
def reset_state(self):
self.lstm.reset_state()
#self.lstm2.reset_state()
def __call__(self, x):
h = self.lstm(x)
# h2 = self.lstm(h)
y = self.out(h2)
return y
错误:unindent 与行上的任何外部缩进级别都不匹配:h2 = self.lstm(h)
米做错了什么?