- Neural Networks with Keras Cookbook
- V Kishore Ayyadevara
- 219字
- 2021-07-02 12:46:25
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.
推薦閱讀
- INSTANT Mock Testing with PowerMock
- Cocos2D-X權威指南(第2版)
- Python量化投資指南:基礎、數據與實戰
- Mastering C# Concurrency
- Python機器學習編程與實戰
- ArcGIS By Example
- 青少年Python編程入門
- D3.js 4.x Data Visualization(Third Edition)
- C語言程序設計
- Python:Deeper Insights into Machine Learning
- 人工智能算法(卷1):基礎算法
- Java Hibernate Cookbook
- Mastering Leap Motion
- INSTANT Premium Drupal Themes
- 軟件設計模式(Java版)