我有4个通道的时间序列数据,并试图使用我的模型生成长度为N的序列.我从提供给我的序列生成函数的输入数据中确定N:
def generate_sequence(self, input_data):
predicted_sequence = tf.convert_to_tensor(input_data, dtype=tf.float32)
data_shape = predicted_sequence.shape
for i in range(len(predicted_sequence)):
model_input = tf.reshape(predicted_sequence, shape=data_shape)
result = self.model(model_input)
predicted_sequence = tf.concat([predicted_sequence[:, 1:, :], result], 0)
return predicted_sequence
这会导致以下错误:
ConcatOp : Dimension 1 in both shapes must be equal: shape[0] = [1,1439,4] vs. shape[1] = [1,1,4] [Op:ConcatV2] name: concat
这似乎表明我使用了错误的方法来生成我的序列(我天真地编写了这个函数,假设tensorflow张量的行为类似numpy数组).在我的循环中,我从输入数据开始:
[[[a1, b1, c1, d1]
[a2, b2, c2, d2]
...
[aN, bN, cN, dN]]
然后我用我的模型生成一个预测
[[aP1, bP1, cP1, dP1]]
这里我的意图是删除输入数据中的第一个条目,因为它是最老的一行数据,并将预测数据添加到最后:
[[[a2, b2, c2, b2]
[a3, b3, c3, d3]
...
[aN, bN, cN, dN]
[aP1, bP1, cP1, dP1]]]
从这里运行循环,直到整个序列包含下N行数据的预测.
有没有另一种tensorflow方法更适合这个问题,或者我在tf.concat
方法中遗漏了什么?
任何帮助将不胜感激.