官术网_书友最值得收藏!

How it works...

The key steps that we have performed in the preceding code are as follows:

  • We flattened the input dataset so that each pixel is considered a variable using the reshape method
  • We performed one-hot encoding on the output values so that we can distinguish between different labels using the to_categorical method in the np_utils package
  • We built a neural network with a hidden layer using the sequential addition of layers
  • We compiled the neural network to minimize the categorical cross entropy loss (as the output has 10 different categories) using the model.compile method
  • We fitted the model with training data using the model.fit method
  • We extracted the training and test loss accuracies across all the epochs that were stored in the history
  • We predicted the probability of each class in the test dataset using the model.predict method
  • We looped through all the images in the test dataset and identified the class that has the highest probability
  • Finally, we calculated the accuracy (the number of instances in which a predicted class matches the actual class of the image out of the total number of instances)

In the next section, we will look at the reasons for the step change in the loss and accuracy values, and move toward making the change more smooth.

主站蜘蛛池模板: 革吉县| 宣城市| 射阳县| 萨嘎县| 宣汉县| 商水县| 上蔡县| 阜新市| 左贡县| 泰安市| 辽阳市| 孙吴县| 宁明县| 秦皇岛市| 安吉县| 文安县| 名山县| 石景山区| 丰都县| 信丰县| 平远县| 宜川县| 红桥区| 关岭| SHOW| 阿瓦提县| 曲水县| 宜昌市| 上蔡县| 黄浦区| 青川县| 会理县| 衡阳县| 逊克县| 柳林县| 旬阳县| 密云县| 通山县| 梓潼县| 正安县| 抚州市|