我尝试使用keras随机生成时间序列数据,如下所示:
import tensorflow as tf
import pandas as pd
import random
input_data = [random.uniform(10,100) for _ in range(350000)]
targets = [random.uniform(10,100) for _ in range(350000)]
dataset = tf.keras.utils.timeseries_dataset_from_array(
input_data, targets, sequence_length=10000)
for batch in dataset:
inputs, targets = batch
break
但最后的形状是减少和未来作为:
<tf.Tensor: shape=(128, 10000), dtype=float32, numpy=
array([[22.922523, 44.253967, 41.80049 , ..., 60.444836, 14.977458,
17.970036],
[44.253967, 41.80049 , 34.09485 , ..., 14.977458, 17.970036,
68.27751 ],
[41.80049 , 34.09485 , 37.27845 , ..., 17.970036, 68.27751 ,
98.05703 ],
...,
[13.941159, 51.48634 , 61.248505, ..., 98.093346, 67.3885 ,
34.01148 ],
[51.48634 , 61.248505, 77.34204 , ..., 67.3885 , 34.01148 ,
27.165142],
[61.248505, 77.34204 , 54.856853, ..., 34.01148 , 27.165142,
97.55085 ]], dtype=float32)>
如何增加数组的大小,或者有什么限制吗?
1条答案
按热度按时间t9aqgxwy1#
将
VARIABLE
更改为所需的样本数(batch_size)。如果需要整个数据,则可以将batch_size=None