Keras Stateful LSTM fit_generator how to use batch_size > 1

你。 提交于 2019-12-05 18:24:23

You will have to modify your generator to yeld the desired number of elements you want your batch to have.

Currently you are iterating over your data element by element (as per your third parameter of range()), obtaining a single x and y, and then yielding that element. As you are returning a single element you are obtaining a batch_size=1, as your fit_generator is training element by element.

Say you want your batch size to be 10, you will then have to slice your data and obtain segments of 10 elements each, and yield those slices instead of single elements. Just be sure that you reflect those changes accordingly on the shape of your Input layers, passing the corresponding batch_size.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!