时间序列发生器
time-series-generator的Python项目详细描述
时间序列发生器
说明
模拟Teras Tensorflow TimeSeriesGenerator功能,为Keras版本中的直接多步输出限制提供一个候选解决方案。在
安装
pip install time-series-generator
使用
^{pr2}$试验
在终端项目根文件夹中运行:
pytest
Keras版本限制
A limitation of the Keras TimeseriesGenerator is that it does not directly support multi-step outputs. Specifically, it will not create the multiple steps that may be required in the target sequence.
Nevertheless, if you prepare your target sequence to have multiple steps, it will honor and use them as the output portion of each sample. This means the onus is on you to prepare the expected output for each time step.
布朗利,杰森
建议的候选改进
添加关键字参数length_output
。在
# define datasetseries=np.array([1,2,3,4,5,6,7,8,9,10])target=np.array([1,2,3,4,5,6,7,8,9,10])# define generatorn_input=2n_output=2generator=TimeseriesGenerator(series,target,length=n_input,length_output=n_output,batch_size=1)# print each sampleforiinrange(len(generator)):x,y=generator[i]print('%s => %s'%(x,y))
输出
[[1 2]] => [[3 4]] [[2 3]] => [[4 5]] [[3 4]] => [[5 6]] [[4 5]] => [[6 7]] [[5 6]] => [[7 8]] [[6 7]] => [[8 9]] [[7 8]] => [[9 10]]
参考文献
- 项目
标签: