Skip to content
Advertisement

Keras, simple neural network Error Code (model.predict)

Do any of you know why I get the following error code?

My Code :

JavaScript

You can ignore the Integrator Part, I just want to know why the model.predict wont work. Here is the error:

JavaScript

Advertisement

Answer

The problem is with the lines:

JavaScript

Here your model is setup to receive a rank 2 tensor as input, but you are only giving it a rank 1 tensor (vector) as input. You need to expand the dimension by 1, like this:

JavaScript

You will then be giving it a test.shape = (1,2) tensor (rank 2) and it should now work without error.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement