paddle报ValueError: The type of data we are trying to retrieve does not match the type
Posted 修炼之路
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了paddle报ValueError: The type of data we are trying to retrieve does not match the type相关的知识,希望对你有一定的参考价值。
错误原因
在使用paddlepaddle训练模型的时候,使用numpy随机生成一些数据来训练一个线程模型的时候报The type of data we are trying to retrieve does not match the type of data currently contained in the container
错误信息
pre_bias = _C_ops.matmul_v2(x, weight, 'trans_x', False, 'trans_y',
ValueError: (InvalidArgument) The type of data we are trying to retrieve does not match the type of data currently contained in the container.
[Hint: Expected dtype() == paddle::experimental::CppTypeToDataType<T>::Type(), but received dtype():12 != paddle::experimental::CppTypeToDataType<T>::Type():13.] (at /paddle/paddle/phi/core/dense_tensor.cc:137)
[operator < matmul_v2 > error]
原因分析及解决办法
因为np.random.rand
生成的数据默认是float64
的数据类型,而paddlepaddle是不支持的,所以我们需要将其转换成为float32
的数据类型,转换代码如下
np.random.rand(num_samples,2).astype("float32")
以上是关于paddle报ValueError: The type of data we are trying to retrieve does not match the type的主要内容,如果未能解决你的问题,请参考以下文章
paddle报ValueError: The type of data we are trying to retrieve does not match the type
paddle报ValueError: (InvalidArgument) Pass tensorrt_subgraph_pass has not been registered
paddle报ValueError: (InvalidArgument) Pass tensorrt_subgraph_pass has not been registered
paddle报ValueError: (InvalidArgument) Pass tensorrt_subgraph_pass has not been registered
解决报错:使用seaborn绘制计数图时出现错误:ValueError: s must be a scalar, or the same size as x and y(图文并茂版!!)
Tensorflow+keras解决Exception has occurred: ValueError Shape mismatch: The shape of labels (received(代