3 from keras.models
import Sequential
4 from keras.layers.core
import Dense, Activation
5 from keras.regularizers
import l2
6 from keras.optimizers
import SGD
12 nodes_hidden_layer = 64
19 model.add(Dense(nodes_hidden_layer, activation=
'relu', W_regularizer=l2(l2_val), input_dim=num_input_nodes))
23 for k
in range(num_hidden_layers-1):
24 model.add(Dense(nodes_hidden_layer, activation=
'relu', W_regularizer=l2(l2_val)))
31 model.add(Dense(num_output_nodes, activation=
'softmax'))
37 model.compile(loss=
'categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=[
'accuracy',])
40 model.save(
'model.h5')
50 from keras.utils.visualize_util
import plot
51 plot(model, to_file=
'model.png', show_shapes=
True)
53 print(
'[INFO] Failed to make model plot')