@@ -19,12 +19,12 @@ Static model
1919 def get_model (inputs_shape ):
2020 ni = Input(inputs_shape)
2121 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
2323 nn = Dropout(keep = 0.8 )(nn)
2424 nn = Dense(n_units = 800 , act = tf.nn.relu)(nn)
2525 nn = Dropout(keep = 0.8 )(nn)
2626 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
2828 return M
2929
3030 MLP = get_model([None , 784 ])
@@ -46,9 +46,9 @@ In this case, you need to manually input the output shape of the previous layer
4646
4747 self .dropout1 = Dropout(keep = 0.8 )
4848 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 )
5050 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 )
5252 self .dense3 = Dense(n_units = 10 , act = tf.nn.relu, in_channels = 800 )
5353
5454 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
5959 z = self .dropout3(z)
6060 out = self .dense3(z)
6161 if foo:
62- out = tf.nn.relu (out)
62+ out = tf.nn.softmax (out)
6363 return out
6464
6565 MLP = CustomModel()
0 commit comments