- Neural Networks with Keras Cookbook
- V Kishore Ayyadevara
- 265字
- 2021-07-02 12:46:24
Getting ready
Training a neural network is done in the following steps:
- Import the relevant packages and datasets
- Preprocess the targets (convert them into one-hot encoded vectors) so that we can perform optimization on top of them:
- We shall be minimizing categorical cross entropy loss
- Create train and test datasets:
- We have the train dataset so that we create a model based on it
- The test dataset is not seen by the model:
- Hence, the accuracy on the test dataset is an indicator of how well the model is likely to work on data when the model is productionalized, as data in the production scenario (which might occur a few days/weeks after building the model) cannot be seen by the model
- Initialize a model
- Define the model architecture:
- Specify the number of units in a hidden layer
- Specify the activation function that is to be performed in a hidden layer
- Specify the number of hidden layers
- Specify the loss function that we want to minimize
- Provide the optimizer that will minimize the loss function
- Fit the model:
- Mention the batch size to update weights
- Mention the total number of epochs
- Test the model:
- Mention the validation data, otherwise, mention the validation split, which will consider the last x% of total data as test data
- Calculate the accuracy and loss values on top of the test dataset
- Check for anything interesting in the way in which loss value and accuracy values changed over an increasing number of epochs
Using this strategy, let's go ahead and build a neural network model in Keras, in the following section.
推薦閱讀
- What's New in TensorFlow 2.0
- Django:Web Development with Python
- 名師講壇:Java微服務架構實戰(SpringBoot+SpringCloud+Docker+RabbitMQ)
- STM32F0實戰:基于HAL庫開發
- Python 3破冰人工智能:從入門到實戰
- FPGA Verilog開發實戰指南:基于Intel Cyclone IV(進階篇)
- AIRIOT物聯網平臺開發框架應用與實戰
- Java面向對象程序設計
- Unity 3D/2D移動開發實戰教程
- JavaScript腳本特效編程給力起飛
- The Statistics and Calculus with Python Workshop
- Mastering JavaScript
- Visual Basic語言程序設計基礎(第3版)
- HTML5移動前端開發基礎與實戰(微課版)
- JavaScript Mobile Application Development