小编And*_*ndy的帖子

有状态LSTM:何时重置状态?

给定具有维度的X (m个样本,n个序列和k个特征),以及具有维度的y个标签(m个样本,0/1):

假设我想训练一个有状态的LSTM(通过keras定义,其中"stateful = True"意味着每个样本的序列之间没有重置单元状态 - 如果我错了请纠正我!),是否应该重置状态在每个时期每个样本的基础上?

例:

for e in epoch:
    for m in X.shape[0]:          #for each sample
        for n in X.shape[1]:      #for each sequence
            #train_on_batch for model...
            #model.reset_states()  (1) I believe this is 'stateful = False'?
        #model.reset_states()      (2) wouldn't this make more sense?
    #model.reset_states()          (3) This is what I usually see...
Run Code Online (Sandbox Code Playgroud)

总之,我不确定是否在每个序列或每个时期之后重置状态(在所有m个样本都在X中训练之后).

建议非常感谢.

python machine-learning lstm keras recurrent-neural-network

7
推荐指数
1
解决办法
2241
查看次数