Created by: hong19860320
assign OP 报错信息添加 1 .添加了对输入Tensor的类型的检查 代码:
import paddle.fluid as fluid
import numpy as np
x1 = fluid.create_lod_tensor(np.array([[-1]]), [[1]], fluid.CPUPlace())
out = fluid.layers.assign(x1)
报错信息:
TypeError: The type of 'input' in assign must be Variable or numpy.ndarray, but received <class 'paddle.fluid.core_avx.LoDTensor'>
2 .添加了对输入Tensor的数据类型的检查 代码:
import paddle.fluid as fluid
import numpy as np
x2 = fluid.layers.data(name='x2', shape=[4], dtype="bool")
out = fluid.layers.assign(x2)
x3 = fluid.layers.data(name='x3', shape=[4], dtype="float16")
out = fluid.layers.assign(x3)
x4 = fluid.layers.data(name='x4', shape=[4], dtype="uint8")
out = fluid.layers.assign(x4)
x5 = np.array([[2.5, 2.5]], dtype='bool')
out = fluid.layers.assign(x5)
x6 = np.array([[2.5, 2.5]], dtype='float16')
out = fluid.layers.assign(x6)
x7 = np.array([[2.5, 2.5]], dtype='float64')
out = fluid.layers.assign(x7)
x8 = np.array([[2.5, 2.5]], dtype='int64')
out = fluid.layers.assign(x8)
x9 = np.array([[2.5, 2.5]], dtype='uint8')
out = fluid.layers.assign(x9)
报错信息:
TypeError: When the type of 'input' in assign is Variable, the data type of 'input' must be float32, float64, int32 or int64, but received bool.
TypeError: When the type of 'input' in assign is Variable, the data type of 'input' must be float32, float64, int32 or int64, but received float16.
TypeError: When the type of 'input' in assign is Variable, the data type of 'input' must be float32, float64, int32 or int64, but received uint8.
TypeError: When the type of 'input' in assign is numpy.ndarray, the data type of 'input' must be float32 or int32, but received bool.
TypeError: When the type of 'input' in assign is numpy.ndarray, the data type of 'input' must be float32 or int32, but received float16.
TypeError: When the type of 'input' in assign is numpy.ndarray, the data type of 'input' must be float32 or int32, but received float64.
TypeError: When the type of 'input' in assign is numpy.ndarray, the data type of 'input' must be float32 or int32, but received int64.
TypeError: When the type of 'input' in assign is numpy.ndarray, the data type of 'input' must be float32 or int32, but received uint8.