@@ -19,12 +19,12 @@ Static model
19
19
def get_model (inputs_shape ):
20
20
ni = Input(inputs_shape)
21
21
nn = Dropout(keep = 0.8 )(ni)
22
- nn = Dense(n_units = 800 , act = tf.nn.relu, name = " dense1" )(nn)
22
+ nn = Dense(n_units = 800 , act = tf.nn.relu, name = " dense1" )(nn) # “name" is optional
23
23
nn = Dropout(keep = 0.8 )(nn)
24
24
nn = Dense(n_units = 800 , act = tf.nn.relu)(nn)
25
25
nn = Dropout(keep = 0.8 )(nn)
26
26
nn = Dense(n_units = 10 , act = tf.nn.relu)(nn)
27
- M = Model(inputs = ni, outputs = nn, name = " mlp" )
27
+ M = Model(inputs = ni, outputs = nn, name = " mlp" ) # “name" is optional
28
28
return M
29
29
30
30
MLP = get_model([None , 784 ])
@@ -46,9 +46,9 @@ In this case, you need to manually input the output shape of the previous layer
46
46
47
47
self .dropout1 = Dropout(keep = 0.8 )
48
48
self .dense1 = Dense(n_units = 800 , act = tf.nn.relu, in_channels = 784 )
49
- self .dropout2 = Dropout(keep = 0.8 )# (self.dense1)
49
+ self .dropout2 = Dropout(keep = 0.8 )
50
50
self .dense2 = Dense(n_units = 800 , act = tf.nn.relu, in_channels = 800 )
51
- self .dropout3 = Dropout(keep = 0.8 )# (self.dense2)
51
+ self .dropout3 = Dropout(keep = 0.8 )
52
52
self .dense3 = Dense(n_units = 10 , act = tf.nn.relu, in_channels = 800 )
53
53
54
54
def forward (self , x , foo = False ):
@@ -59,7 +59,7 @@ In this case, you need to manually input the output shape of the previous layer
59
59
z = self .dropout3(z)
60
60
out = self .dense3(z)
61
61
if foo:
62
- out = tf.nn.relu (out)
62
+ out = tf.nn.softmax (out)
63
63
return out
64
64
65
65
MLP = CustomModel()
0 commit comments