3 from keras.models
import Sequential
4 from keras.layers.core
import Dense, Activation
5 from keras.regularizers
import l2
6 from keras
import initializations
7 from keras.optimizers
import SGD
13 nodes_hidden_layer = 64
20 return initializations.normal(shape, scale=0.05, name=name)
26 model.add(Dense(nodes_hidden_layer, init=normal, activation=
'relu', W_regularizer=l2(l2_val), input_dim=num_input_nodes))
30 for k
in range(num_hidden_layers-1):
31 model.add(Dense(nodes_hidden_layer, init=normal, activation=
'relu', W_regularizer=l2(l2_val)))
38 model.add(Dense(num_output_nodes, init=normal, activation=
'softmax'))
44 model.compile(loss=
'categorical_crossentropy', optimizer=SGD(lr=0.01), metrics=[
'accuracy',])
47 model.save(
'model.h5')
57 from keras.utils.visualize_util
import plot
58 plot(model, to_file=
'model.png', show_shapes=
True)
60 print(
'[INFO] Failed to make model plot')
def normal(shape, name=None)