Created
February 7, 2021 18:18
-
-
Save maxrohleder/6c49f9c21a84757b1e57b2662d8f6377 to your computer and use it in GitHub Desktop.
this toy-resnet demonstrates the functional api of keras.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from https://www.tensorflow.org/guide/keras/functional#a_toy_resnet_model | |
inputs = keras.Input(shape=(32, 32, 3), name="img") | |
x = layers.Conv2D(32, 3, activation="relu")(inputs) | |
x = layers.Conv2D(64, 3, activation="relu")(x) | |
block_1_output = layers.MaxPooling2D(3)(x) | |
x = layers.Conv2D(64, 3, activation="relu", padding="same")(block_1_output) | |
x = layers.Conv2D(64, 3, activation="relu", padding="same")(x) | |
block_2_output = layers.add([x, block_1_output]) | |
x = layers.Conv2D(64, 3, activation="relu", padding="same")(block_2_output) | |
x = layers.Conv2D(64, 3, activation="relu", padding="same")(x) | |
block_3_output = layers.add([x, block_2_output]) | |
x = layers.Conv2D(64, 3, activation="relu")(block_3_output) | |
x = layers.GlobalAveragePooling2D()(x) | |
x = layers.Dense(256, activation="relu")(x) | |
x = layers.Dropout(0.5)(x) | |
outputs = layers.Dense(10)(x) | |
model = keras.Model(inputs, outputs, name="toy_resnet") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment