Spaces:
Runtime error
Runtime error
Commit
·
7526a8e
1
Parent(s):
bcbe7d2
Updated model reconstruction code
Browse files
app.py
CHANGED
|
@@ -68,25 +68,17 @@ def create_classification_model():
|
|
| 68 |
# print(inputs)
|
| 69 |
|
| 70 |
vision_model.trainable=False
|
| 71 |
-
# vision_model.trainable = True
|
| 72 |
-
# # Fine-tune from this layer onwards
|
| 73 |
-
# fine_tune_at = 100
|
| 74 |
-
|
| 75 |
-
# # Freeze all the layers before the `fine_tune_at` layer
|
| 76 |
-
# for layer in base_model.layers[:fine_tune_at]:
|
| 77 |
-
# layer.trainable = False
|
| 78 |
base_model_output = vision_model(rescaled_input)
|
| 79 |
|
| 80 |
current_layer = base_model_output.pooler_output
|
| 81 |
-
hidden_layers_nodes = [
|
| 82 |
for node_count in hidden_layers_nodes:
|
| 83 |
hidden_layer = tf.keras.layers.Dense(node_count, activation='relu')
|
| 84 |
dropout_layer = tf.keras.layers.Dropout(.2, input_shape=(2,))
|
| 85 |
-
# hidden_layer.trainable = False
|
| 86 |
current_layer = hidden_layer(dropout_layer(current_layer))
|
| 87 |
|
| 88 |
-
prediction_layer = tf.keras.layers.Dense(
|
| 89 |
-
|
| 90 |
outputs = prediction_layer(current_layer)
|
| 91 |
model = tf.keras.Model(inputs, outputs)
|
| 92 |
|
|
@@ -94,10 +86,11 @@ def create_classification_model():
|
|
| 94 |
model.compile(
|
| 95 |
# Used leagcy optimizer due to tf 2.11 release issues with MACOS
|
| 96 |
# optimizer=tf.keras.optimizers.Adam(learning_rate=base_learning_rate),
|
| 97 |
-
optimizer=tf.keras.optimizers.legacy.Adam(
|
|
|
|
| 98 |
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
|
| 99 |
-
metrics=['accuracy']
|
| 100 |
-
steps_per_execution=steps_per_execution
|
| 101 |
)
|
| 102 |
|
| 103 |
return model
|
|
|
|
| 68 |
# print(inputs)
|
| 69 |
|
| 70 |
vision_model.trainable=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
base_model_output = vision_model(rescaled_input)
|
| 72 |
|
| 73 |
current_layer = base_model_output.pooler_output
|
| 74 |
+
hidden_layers_nodes = [1024]
|
| 75 |
for node_count in hidden_layers_nodes:
|
| 76 |
hidden_layer = tf.keras.layers.Dense(node_count, activation='relu')
|
| 77 |
dropout_layer = tf.keras.layers.Dropout(.2, input_shape=(2,))
|
|
|
|
| 78 |
current_layer = hidden_layer(dropout_layer(current_layer))
|
| 79 |
|
| 80 |
+
prediction_layer = tf.keras.layers.Dense(
|
| 81 |
+
classes_count, activation='softmax')
|
| 82 |
outputs = prediction_layer(current_layer)
|
| 83 |
model = tf.keras.Model(inputs, outputs)
|
| 84 |
|
|
|
|
| 86 |
model.compile(
|
| 87 |
# Used leagcy optimizer due to tf 2.11 release issues with MACOS
|
| 88 |
# optimizer=tf.keras.optimizers.Adam(learning_rate=base_learning_rate),
|
| 89 |
+
optimizer=tf.keras.optimizers.legacy.Adam(
|
| 90 |
+
learning_rate=base_learning_rate),
|
| 91 |
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
|
| 92 |
+
metrics=['accuracy']
|
| 93 |
+
# steps_per_execution=steps_per_execution
|
| 94 |
)
|
| 95 |
|
| 96 |
return model
|