我试图建立一个机器学习模型,从一系列数字中预测一个数字.我使用的是Tensorflow的keras API的序列模型.
你可以想象我的数据集是这样的:
Index | x data | y data |
---|---|---|
0 | np.ndarray(shape (1209278,) ) |
numpy.float32 |
1 | np.ndarray(shape (1211140,) ) |
numpy.float32 |
2 | np.ndarray(shape (1418411,) ) |
numpy.float32 |
3 | np.ndarray(shape (1077132,) ) |
numpy.float32 |
... | ... | ... |
This was my first attempt:
我try 使用一个包含numpy ndarray的numpy ndarray作为扩展数据,它最终包含浮点值,如下所示:
array([
array([3.59280851, 3.60459062, 3.60459062, ..., 4.02911493])
array([3.54752101, 3.56740332, 3.56740332, ..., 4.02837855])
array([3.61048168, 3.62152741, 3.62152741, ..., 4.02764217])
])
我的y数据是一个包含浮点的numpy数组,看起来像这样
array([2.9864411, 3.0562437, ... , 2.7750807, 2.8712902], dtype=float32)
但当我try 使用model.fit()
训练模型时,它产生了以下错误:
ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type numpy.ndarray).
我通过问一个与此相关的问题来解决这个错误:
My latest attempt:
[
array([3.59280851, 3.60459062, 3.60459062, ..., 4.02911493])
array([3.54752101, 3.56740332, 3.56740332, ..., 4.02837855])
array([3.61048168, 3.62152741, 3.62152741, ..., 4.02764217])
]
我没有动我的y数据,所以是一堆浮点数据.
ValueError: Data cardinality is ambiguous:
x sizes: 1304593, 1209278, 1407624, ...
y sizes: 46
Make sure all arrays contain the same number of samples.
如您所见,我的x数据由具有不同形状的数组组成.
Question:
我猜想Tensorflow试图使用我的数组列表作为multiple个输入.
但我不想使用我的x数据作为多个输入.
- 数组([3.59280851,3.60459062,3.60459062,…])=&燃气轮机;2.8989773
- 数组([3.54752101,3.56740332,3.56740332,…])=&燃气轮机;3.0893357
- ...
How can I use a sequence of numbers to predict a single number in Tensorflow?
EDIT
总而言之,我认为我的问题相当笼统,如果你知道如何解决这个问题,应该很容易回答,不像我.