herpaderpapotato commited on
Commit
c4bd4b0
1 Parent(s): cff09c6

Create initial_model_creation.py

Browse files
Files changed (1) hide show
  1. initial_model_creation.py +43 -0
initial_model_creation.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ policy = tf.keras.mixed_precision.Policy("mixed_float16")
3
+ tf.keras.mixed_precision.set_global_policy(policy)
4
+ from tensorflow import keras
5
+ from tensorflow.keras import layers
6
+ from keras_cv_attention_models import efficientnet
7
+
8
+ input_shape = (image_frames, None, None, 3)
9
+ image_frames = 60
10
+ image_size = 384
11
+
12
+ backbone_path = 'efficientnetv2-s-21k-ft1k.h5'
13
+ backbone = efficientnet.EfficientNetV2S(pretrained=backbone_path,dropout=1e-6, num_classes=0, include_preprocessing = True)
14
+ backbone.summary()
15
+ backbone.trainable = False
16
+
17
+ inputs = keras.Input(shape=input_shape)
18
+ backbone_inputs = keras.Input(shape=(None, None, 3))
19
+ y = backbone(backbone_inputs)
20
+ y = layers.Flatten()(y)
21
+ y = layers.Dense(32, activation="relu")(y)
22
+ y = layers.Dropout(0.1)(y)
23
+ x = layers.TimeDistributed(keras.Model(backbone_inputs, y))(inputs)
24
+ x = layers.Dropout(0.1)(x)
25
+ x = layers.LSTM(128, return_sequences=True)(x)
26
+ x = layers.Dropout(0.1)(x)
27
+ x = layers.LSTM(128, return_sequences=False)(x)
28
+ x = layers.Dropout(0.1)(x)
29
+ x = layers.Dense(128, activation="relu")(x)
30
+ x = layers.Dropout(0.1)(x)
31
+ x = layers.Dense(64, activation="relu")(x)
32
+ x = layers.Dropout(0.1)(x)
33
+ x = layers.Dense(48, activation="relu")(x)
34
+ x = layers.Dropout(0.1)(x)
35
+ x = layers.Dense(32, activation="relu")(x)
36
+ x = layers.Dropout(0.1)(x)
37
+ outputs = layers.Dense(9, activation="relu")(x)
38
+ model = keras.Model(inputs, outputs)
39
+ model.compile(
40
+ optimizer=keras.optimizers.Adam(1e-3),
41
+ loss="mean_squared_error",
42
+ metrics=["mean_squared_error", "mean_absolute_error"]
43
+ )