Spaces:
Runtime error
Runtime error
Update modelutil.py
Browse files- modelutil.py +18 -14
modelutil.py
CHANGED
@@ -1,20 +1,24 @@
|
|
1 |
import tensorflow as tf
|
2 |
|
3 |
-
|
4 |
-
tf.keras.layers.Dense(300, activation='relu', name="hiddenlayer1"),
|
5 |
-
tf.keras.layers.Dense(100, activation='relu', name="hiddenlayer2"),
|
6 |
-
tf.keras.layers.Dense(10, activation='softmax', name="outputlayer")]
|
7 |
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
model
|
11 |
-
|
12 |
-
|
13 |
-
LOSS_FUNCTION = tf.keras.losses.SparseCategoricalCrossentropy() # HERE
|
14 |
-
OPTIMIZER = "ADAM"
|
15 |
-
METRICS = ["accuracy"]
|
16 |
-
model.compile(loss=LOSS_FUNCTION,
|
17 |
-
optimizer=OPTIMIZER,
|
18 |
-
metrics=METRICS)
|
19 |
|
20 |
|
|
|
1 |
import tensorflow as tf
|
2 |
|
3 |
+
def create_model():
|
|
|
|
|
|
|
4 |
|
5 |
+
LAYERS = [tf.keras.layers.Flatten(input_shape=[28,28], name="inputlayer"),
|
6 |
+
tf.keras.layers.Dense(300, activation='relu', name="hiddenlayer1"),
|
7 |
+
tf.keras.layers.Dense(100, activation='relu', name="hiddenlayer2"),
|
8 |
+
tf.keras.layers.Dense(10, activation='softmax', name="outputlayer")]
|
9 |
+
|
10 |
+
model = tf.keras.models.Sequential(LAYERS)
|
11 |
+
|
12 |
+
model.load_weights('./checkpoint')
|
13 |
+
|
14 |
+
|
15 |
+
LOSS_FUNCTION = tf.keras.losses.SparseCategoricalCrossentropy() # HERE
|
16 |
+
OPTIMIZER = "ADAM"
|
17 |
+
METRICS = ["accuracy"]
|
18 |
+
model.compile(loss=LOSS_FUNCTION,
|
19 |
+
optimizer=OPTIMIZER,
|
20 |
+
metrics=METRICS)
|
21 |
|
22 |
+
return model
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
|