报错InvalidArgumentError: Tensor holds the wrong type
Created by: hubu-wangpei
以下代码使用fluid.layers.softmax_with_cross_entropy(logits, label),报错
x_data, y_data = data
#print(x_data,y_data)
img = fluid.dygraph.to_variable(x_data)
label = fluid.dygraph.to_variable(y_data)
label=fluid.layers.cast(label,np.int64)
label=fluid.one_hot(label,2)
# 运行模型前向计算,得到预测值
logits = model(img)
print(logits)
# 进行loss计算
loss = fluid.layers.softmax_with_cross_entropy(logits, label)
报错信息
Error Message Summary:---------------------- InvalidArgumentError: Tensor holds the wrong type, it holds float, but desires to be int64_t. [Hint: Expected valid == true, but received valid:0 != true:1.] at (/paddle/paddle/fluid/framework/tensor_impl.h:33)