python - timeseries_dataset_from_array 产生 4d 数组
问题描述
我正在使用timeseries_dataset_from_array
fromtensorflow.keras.preprocessing
为LSTM
模型生成时间序列。
我的输入data
是一个 2Dnumpy.ndarray
的 shape (2500, 9)
。
我正在创建这样的时间序列:
input_dataset = timeseries_dataset_from_array(data=data, targets=None, sequence_length=70, batch_size=1)
然后我转换input_dataset
为一个 numpy 数组:
input_as_list = list(input_dataset)
input_np = np.stack(input_as_list) # same output with np.asarray
然而 的形状等input_as_list
是input_np
4D: (2500, 1, 70, 9)
。
为了绕过我正在重塑input_np
为 3D 的问题。由于batch_size
设置为 1,这非常简单:
input_np_3d = np.reshape(input_np, [input_np.shape[0], input_np.shape[2], input_np.shape[3]])
然而这感觉不对。默认情况下不应该timeseries_dataset_from_array
生成 3D 时间序列吗?我错过了什么?
解决方案
推荐阅读
- odoo - Changes in quants in Odoo 11 , 12
- javascript - 引导模态的位置不正确
- neural-network - 如何创建 ONNX 文件?
- ios - ionic 3 支持的最低 iOS 版本是多少?
- elasticsearch - 如何将kibana中的查询输出表示为图形?
- xpath - 如何针对从正则表达式提取器提取的值运行每个循环
- kerberos - Ambari 在安装 Kerberos 时无法创建主体
- php - 从服务器获取数据时如何保持选中动态单选按钮
- apache-camel - apache camel - seda 端点多播
- filter - 根据日期删除重复响应