Keras 剩余LSTM层

Keras 剩余LSTM层,keras,lstm,deep-residual-networks,Keras,Lstm,Deep Residual Networks,我很难理解keras中LSTM层的张量行为 我对数字数据进行了预处理,这些数据看起来像[样本、时间步长、特征]。因此,10000个样本,24个时间步和10个预测值 我想堆叠剩余连接,但我不确定是否正确: x <- layer_input(shape = c(24,10)) x <- layer_lstm(x,units=32,activation="tanh",return_sequences=T) 现在x的形状,也就是张量,是[?,?,32]。我在期待[?,32,10]。我是否

我很难理解keras中LSTM层的张量行为

我对数字数据进行了预处理,这些数据看起来像[样本、时间步长、特征]。因此,10000个样本,24个时间步和10个预测值

我想堆叠剩余连接,但我不确定是否正确:

x <- layer_input(shape = c(24,10))

x <- layer_lstm(x,units=32,activation="tanh",return_sequences=T)
现在x的形状,也就是张量,是[?,?,32]。我在期待[?,32,10]。我是否应该将数据重塑为[样本、特征、时间步长]?然后我形成res:

y <- layer_lstm(x,units=32,activation="tanh",return_sequences=T)

res <- layer_add(c(x, y))
现在我不确定这是不是正确的,或者我应该用它来代替

x <- layer_input(shape = c(24,10))

y <- layer_lstm(x,units=24,activation="tanh",return_sequences=T) # same as time_steps

res <- layer_add(c(x,y)) ## perhaps here data reshaping is neccesary?
任何洞见都是值得赞赏的

JJ

LSTM层将返回dims作为?,seq_length,out_dims,其中out_dims是您案例中的单位。因此,整体DIM将如下所示:

x <- layer_input(shape = c(24,10))
# dims of x (?,24,10)
x <- layer_lstm(x,units=32,activation="tanh",return_sequences=T)
# dims of x after lstm_layer (?,24,32)

y <- layer_lstm(x,units=32,activation="tanh",return_sequences=T)
# dims of y (?,24,32)
res <- layer_add(c(x, y))
# dims of res will be (?,24,32), it is addion of output of both lstm_layer.

要了解更多信息,您可以

这样LSTM将获取所有10个预测值,并组合24个序列,其中将包含所有10个预测值的信息?我没听错吧@Ankish BansalYeah,这里的序列可以看作是时间步,所以每个时间步需要10个预测器,计算32个DIM的输出,然后重复24个时间步。我只需要再问一个子问题。因此,如果我担心在更深的层中丢失信息,这些层与另一个res叠加在一起,我应该在我们的例子中保存第一个x,然后再添加它@Ankish BansalI不明白,你是说,如果你再添加一个res块呢?同样,使用剩余层是松散的,但更多的是叠加两层。当我们实际使用残差作为层输出的目标时,使用残差。