- Practical Convolutional Neural Networks
- Mohit Sewak Md. Rezaul Karim Pradeep Pujari
- 188字
- 2021-06-24 18:58:52
Building the network
For this example, you'll define the following:
- The input layer, which you should expect for each piece of MNIST data, as it tells the network the number of inputs
- Hidden layers, as they recognize patterns in data and also connect the input layer to the output layer
- The output layer, as it defines how the network learns and gives a label as the output for a given image, as follows:
# Defining the neural network def build_model(): model = Sequential() model.add(Dense(512, input_shape=(784,))) model.add(Activation('relu')) # An "activation" is just a non-linear function that is applied to the output # of the above layer. In this case, with a "rectified linear unit", # we perform clamping on all values below 0 to 0. model.add(Dropout(0.2)) #With the help of Dropout helps we can protect the model from memorizing or "overfitting" the training data model.add(Dense(512)) model.add(Activation('relu')) model.add(Dropout(0.2)) model.add(Dense(10)) model.add(Activation('softmax')) # This special "softmax" activation, #It also ensures that the output is a valid probability distribution, #Meaning that values obtained are all non-negative and sum up to 1. return model
#Building the model model = build_model()
model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
推薦閱讀
- 數據可視化:從小白到數據工程師的成長之路
- Google Visualization API Essentials
- SQL Server 2008數據庫應用技術(第二版)
- Access 2007數據庫應用上機指導與練習
- Python金融實戰
- 智能數據時代:企業大數據戰略與實戰
- Learning Proxmox VE
- 一本書講透Elasticsearch:原理、進階與工程實踐
- SAS金融數據挖掘與建模:系統方法與案例解析
- 貫通SQL Server 2008數據庫系統開發
- Web Services Testing with soapUI
- 大數據數學基礎(Python語言描述)
- 數據庫應用系統技術
- 算力經濟:從超級計算到云計算
- 云計算