Skip to content

Instantly share code, notes, and snippets.

@StrikingLoo
Created June 12, 2019 17:05
Show Gist options
  • Save StrikingLoo/aa1d1ff7b9c38928d7587e5e6f040201 to your computer and use it in GitHub Desktop.
Save StrikingLoo/aa1d1ff7b9c38928d7587e5e6f040201 to your computer and use it in GitHub Desktop.
fc_layer_size = 128
img_size = IMG_SIZE
conv_inputs = keras.Input(shape=(img_size[1], img_size[0],3), name='ani_image')
conv_layer = layers.Conv2D(24, kernel_size=3, activation='relu')(conv_inputs)
conv_layer = layers.MaxPool2D(pool_size=(2,2))(conv_layer)
conv_x = layers.Flatten(name = 'flattened_features')(conv_layer) #turn image to vector.
conv_x = layers.Dense(fc_layer_size, activation='relu', name='first_layer')(conv_x)
conv_x = layers.Dense(fc_layer_size, activation='relu', name='second_layer')(conv_x)
conv_outputs = layers.Dense(1, activation='sigmoid', name='class')(conv_x)
conv_model = keras.Model(inputs=conv_inputs, outputs=conv_outputs)
customAdam = keras.optimizers.Adam(lr=1e-6)
conv_model.compile(optimizer=customAdam, # Optimizer
# Loss function to minimize
loss="binary_crossentropy",
# List of metrics to monitor
metrics=["binary_crossentropy","mean_squared_error"])
#Epoch 5/5 loss: 1.6900 val_loss: 2.0413 val_mean_squared_error: 0.3688
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment