TypeError:__init __()缺少2个必需的位置参数:“ value_index”和“ dtype”

时间:2020-08-18 04:54:50

标签: tensorflow tensorflow2.0

tf.Tensor([3,2])

执行此操作时,我遇到了

错误
TypeError: __init__() missing 2 required positional arguments: 'value_index' and 'dtype'

1 个答案:

答案 0 :(得分:0)

您正在尝试创建一个新的Tensor对象,但没有提供创建所需的两个参数。

您还需要value_index参数,该参数是产生张量的操作端点的索引,而dtype是张量的数据类型(float32,int64等)

有关示例和任何其他问题,请参考以下方便的指向tf.Tensor文档的链接:https://www.tensorflow.org/api_docs/python/tf/Tensor