我正在尝试将时间序列数据保存并加载到TFRecord
文件中。我几乎成功地做到了。我得到的错误是当我通过模型传递数据时。关于张量的形状,我得到了一个模糊的错误。
我比较了读取TFRecordDataset所得的张量,它们看起来与我相同。是否与我没有从文件中读取MapDataset
而不是DatasetV1Adapter
的事实有关?
最小可复制示例在这里:
https://gist.github.com/vicpara/3b4ea00553a1990620a2df77d8b6aa1f
训练模型时我遇到的错误是
~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/tensorflow_core/python/keras/distribute/distributed_training_utils.py in validate_per_replica_inputs(distribution_strategy, x)
354 if not context.executing_eagerly():
355 # Validate that the shape and dtype of all the elements in x are the same.
--> 356 validate_all_tensor_shapes(x, x_values)
357 validate_all_tensor_types(x, x_values)
358
~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/tensorflow_core/python/keras/distribute/distributed_training_utils.py in validate_all_tensor_shapes(x, x_values)
371 def validate_all_tensor_shapes(x, x_values):
372 # Validate that the shape of all the elements in x have the same shape
--> 373 x_shape = x_values[0].shape.as_list()
374 for i in range(1, len(x_values)):
375 if x_shape != x_values[i].shape.as_list():
~/.pyenv/versions/3.7.4/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py in as_list(self)
1169 """
1170 if self._dims is None:
-> 1171 raise ValueError("as_list() is not defined on an unknown TensorShape.")
1172 return [dim.value for dim in self._dims]
1173
ValueError: as_list() is not defined on an unknown TensorShape.