首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >连续时间序列LSTM stateful 的状态在keras中如何传递?

连续时间序列LSTM stateful 的状态在keras中如何传递?

提问于 2019-01-01 10:44:58
回答 1关注 0查看 595

按照官方文档“stateful: Boolean (default False). If True, the last state for each sample at index i in a batch will be used as initial state for the sample of index i in the following batch.” 如果 x1 和 x2 是连续批次的样本,则x2[i]是 x1[i] 的后续序列,对于每个 i .

那么问题来了,对于以个batchsize>1的训练集,如果序列数据在时间上是连续去且有依赖关系,那么对于stateful lstm 而言,样本的训练将会出现非连续的情况,示例如下,Input 是X 样本矩阵。

X = [ t01 t02 t03 t04 t05 t06 t07 t08 t09 t10 t11 t12 t13 t14 t15 t16 t17 t18 t19 t20 t21 t22 t23 t24 ]

在做输入变量reshape后,按照timestep=4,batch_size=2进行操作,输入变量结构变成如下:

X1 = [ t01 t02 t03 t04 t05 t06 t07 t08 ] X2 = [ t09 t10 t11 t12 t13 t14 t15 t16 ] X3 = [ t17 t18 t19 t20 t21 t22 t23 t25 ]

X1,X2,X3为3个batch, 那么按照官方文档,X1中t04的h,c状态 会被传递给X2的t09 ,而非我期待的t05 , 这个问题如何处理? 请不吝赐教。

相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档