Last active
June 16, 2022 17:56
-
-
Save SmiffyKMc/085da735a034ed396658622be1cdc040 to your computer and use it in GitHub Desktop.
First version of the CNN
This file contains hidden or 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
import tensorflow as tf | |
from tensorflow import keras | |
from keras import layers | |
inputs = keras.Input(shape=(256, 256, 3)) | |
x = layers.Rescaling(1./255)(inputs) | |
x = layers.Conv2D(filters=32, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=64, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=128, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=256, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=256, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.Flatten()(x) | |
x = layers.Dense(516, activation=keras.activations.relu)(x) | |
outputs = layers.Dense(1, activation=keras.activations.sigmoid)(x) | |
model = keras.Model(inputs, outputs) | |
model.compile(optimizer=keras.optimizers.RMSprop(), | |
loss=keras.losses.BinaryCrossentropy(), | |
metrics=["accuracy"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment