error : iterating over `tf.Tensor` is not allowed in Graph execution. Use Eager execution or decorate this function with @tf.function.
通过iterator产生batch数据,在模型中需要使用数据的维度参数,比如data.get_shape().as_list().会报错。此时需要在iterator.get_next()产生的实例化数据做一个尺寸定义。
data.set_shape([1,2,3]), 问题方可解决。
本文介绍了解决在使用TensorFlow迭代器时遇到的形状错误问题。当使用`iterator.get_next()`产生的数据进行操作,并尝试获取其形状时,可能会出现错误提示。文章详细解释了如何通过设置实例化数据的尺寸定义来解决这一问题。

4866

被折叠的 条评论
为什么被折叠?



