wrong reason
When using paddlepaddle to train the model, use numpy to randomly generate some data to train a thread model when reportingThe type of data we are trying to retrieve does not match the type of data currently contained in the container
error message
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]
Cause Analysis and Solutions
Because np.random.rand
the generated data defaults to float64
the data type of , and paddlepaddle does not support it, so we need to convert it into the float32
data type of , the conversion code is as follows
np.random.rand(num_samples,2).astype("float32")