How to train and set up an artificial multilayer perceptron neural network using Keras?

I create my first artificial perceptron multilayer neural network using Keras.

This is my input:

enter image description here

This is my code that I used to create my initial model, which basically follows the Keras code example:

model = Sequential()
model.add(Dense(64, input_dim=14, init='uniform'))
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(64, init='uniform'))
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Dense(2, init='uniform'))
model.add(Activation('softmax'))

sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='mean_squared_error', optimizer=sgd)
model.fit(X_train, y_train, nb_epoch=20, batch_size=16)

Output:

Epoch 1/20
1213/1213 [==============================] - 0s - loss: 0.1760     
Epoch 2/20
1213/1213 [==============================] - 0s - loss: 0.1840     
Epoch 3/20
1213/1213 [==============================] - 0s - loss: 0.1816     
Epoch 4/20
1213/1213 [==============================] - 0s - loss: 0.1915     
Epoch 5/20
1213/1213 [==============================] - 0s - loss: 0.1928     
Epoch 6/20
1213/1213 [==============================] - 0s - loss: 0.1964     
Epoch 7/20
1213/1213 [==============================] - 0s - loss: 0.1948     
Epoch 8/20
1213/1213 [==============================] - 0s - loss: 0.1971     
Epoch 9/20
1213/1213 [==============================] - 0s - loss: 0.1899     
Epoch 10/20
1213/1213 [==============================] - 0s - loss: 0.1957     
Epoch 11/20
1213/1213 [==============================] - 0s - loss: 0.1923     
Epoch 12/20
1213/1213 [==============================] - 0s - loss: 0.1910     
Epoch 13/20
1213/1213 [==============================] - 0s - loss: 0.2104     
Epoch 14/20
1213/1213 [==============================] - 0s - loss: 0.1976     
Epoch 15/20
1213/1213 [==============================] - 0s - loss: 0.1979     
Epoch 16/20
1213/1213 [==============================] - 0s - loss: 0.2036     
Epoch 17/20
1213/1213 [==============================] - 0s - loss: 0.2019     
Epoch 18/20
1213/1213 [==============================] - 0s - loss: 0.1978     
Epoch 19/20
1213/1213 [==============================] - 0s - loss: 0.1954     
Epoch 20/20
1213/1213 [==============================] - 0s - loss: 0.1949

How do I prepare and configure this model and get my code to output my best predictive model? I'm new to neural networks, and I'm just completely confused about what is the next step after creating a model. I know that I want to optimize it, but I'm not sure what functions need to be configured or if I have to do it manually or how to write code for this.

+4
1

, , :

  • mean_squared_error binary_crossentropy. mean_squared_error , .
  • show_accuracy=True fit(), . , , , .
  • validation_split=0.2 fit(). . - , , ( , ).
  • / / . ~ 1200 - . , , . , (, ), , , , , , , Republican.
  • , 0 1 ( (max-min) ). , .
  • Adam Adagrad SGD. . (. .)
  • Activation('relu'), LeakyReLU, PReLU ELU Activation('tanh'). . (. .)
  • / (, 64 128). / .
  • BatchNormalization ( Activation). (. .)
  • (, 0.5 0.25).
+9

Source: https://habr.com/ru/post/1623397/


All Articles