We will use the Keras model’s predict
method to look at the predicted class value. Then we will use the predict_classes
method to have Keras make a class prediction for us, and return only a 0 or a 1, which represents the predicted class.
Instructor: [00:01] Our neural network takes in four numerical values and predicts a class of zero, if the values are low, and one, if the values are high. After the neural network is trained, make some inputs to test that are NumPy arrays of four values each. Then, we will call the models predict method to make predictions on those inputs and print the output to the screen.
[00:28] When we run that, we see that the network returns a floating point value and not a class of zero or one like you might expect. What you are seeing is the raw output from the sigmoid function that we defined on the output node and not the classes as we define them.
[00:48] We could round these predicted values to get to a class, or we'd have Keras do that for us by calling the predict classes method instead of just predict. Once we change to that, we see the proper classes for our input data.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!