import tensorflow as tf
inputs = tf.keras.layers.Input(shape=(256, 256, 3)) x = tf.keras.layers.Conv2D( filters=64, kernel_size=(3, 3), activation='relu', padding='same', name='block1_conv1')(inputs) x = tf.keras.layers.Conv2D( filters=64, kernel_size=(3, 3), activation="relu", padding="same", name="block1_conv2")(x) x = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2, name='block1_pool')(x)
x = tf.keras.layers.Conv2D( filters=128, kernel_size=(3, 3), activation='relu', padding='same', name='block2_conv1')(x) x = tf.keras.layers.Conv2D( filters=128, kernel_size=(3, 3), activation='relu', padding='same', name='block2_conv2')(x) x = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2, name='block2_pool')(x)
x = tf.keras.layers.Conv2D( filters=256, kernel_size=(3, 3), activation='relu', padding='same', name='block3_conv1')(x) x = tf.keras.layers.Conv2D( filters=256, kernel_size=(3, 3), activation='relu', padding='same', name='block3_conv2')(x) x = tf.keras.layers.Conv2D( filters=256, kernel_size=(3, 3), activation='relu', padding='same', name='block3_conv3')(x) x = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2, name='block3_pool')(x) block3_pool = x
x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block4_conv1')(x) x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block4_conv2')(x) x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block4_conv3')(x) x = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2, name='block4_pool')(x) block4_pool = x
x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block5_conv1')(x) x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block5_conv2')(x) x = tf.keras.layers.Conv2D( filters=512, kernel_size=(3, 3), activation='relu', padding='same', name='block5_conv3')(x) x = tf.keras.layers.MaxPooling2D(pool_size=(2, 2), strides=2, name='block5_pool')(x) block5_pool = x
outputs = tf.keras.layers.Conv2D( filters=3, kernel_size=(7, 7), activation='relu', padding='same', name='conv6')(block5_pool) conv6_4 = tf.keras.layers.Conv2DTranspose( filters=3, kernel_size=(4, 4), strides=4, use_bias=False)(outputs)
pool4_n = tf.keras.layers.Conv2D( filters=3, kernel_size=(1, 1), activation='relu', padding='same', name='pool4_n')(block4_pool) pool4_n_2 = tf.keras.layers.Conv2DTranspose( filters=3, kernel_size=(2, 2), strides=2, use_bias=False)(pool4_n)
pool3_n = tf.keras.layers.Conv2D( filters=3, kernel_size=(3, 3), activation='relu', padding='same', name='pool3_n')(block3_pool)
output = tf.keras.layers.Add(name='add')([pool4_n_2, pool3_n, conv6_4]) output = tf.keras.layers.Conv2DTranspose(filters=3, kernel_size=(8, 8), strides=8, use_bias=False)(output) output = tf.keras.layers.Softmax()(output)
fcn_model = tf.keras.models.Model(inputs, output)
fcn_model.compile( loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True), optimizer=tf.keras.optimizers.RMSprop(), metrics=['accuracy'])
fcn_model.summary()
|