Tensorflow ValueError: Failed to convert a NumPy array to a Tensor

    Recently, I’m learning to build tensorflow and keras. There are always all kinds of errors. Thank you very much for your experience. I will see how you solve the problem every time. Of course, some solutions have been tried and found not to work, so we have to continue to look for solutions.

      I will share with you the problems I have encountered and the final solution. In the process, I should refer to the content shared by many predecessors. As a knowledge transmitter, I hope my sharing and summary can also help you.

     


ValueError: Failed to convert a NumPy array to a Tensor

      Thanks to bloggers for solving this problem( https://blog.csdn.net/weixin_ 39653948/article/details/105132995).

Error reason: before training the model, the training samples and test samples were not converted into data types acceptable to tensorflowh and keras.

resolvent:

x_train=x_train.astype('float64')
x_test=x_test.astype('float64')

    The error is removed and the program is running normally.

    Thanks again for sharing.

 

Read More: