Skip to content

Instantly share code, notes, and snippets.

@Cospel
Created January 17, 2020 13:34
Show Gist options
  • Select an option

  • Save Cospel/43d95f9b884bb7e7cd8227bf2b191652 to your computer and use it in GitHub Desktop.

Select an option

Save Cospel/43d95f9b884bb7e7cd8227bf2b191652 to your computer and use it in GitHub Desktop.
normalized_model.py
# create the base model
base_model = tf.keras.applications.MobileNetV2(include_top=False, weights="imagenet", input_shape=shape)
# apply normalization on input
inputs = tf.keras.Input(shape=shape, name="input")
x = PreprocessTFLayer()(inputs)
x = base_model(x)
x = tf.keras.layers.GlobalAveragePooling2D()(x)
outputs = tf.keras.layers.Dense(2, activation="softmax", name="probs")(x)
# create the model
model = tf.keras.Model(inputs=inputs, outputs=outputs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment