text_plain_output_1.png
from tensorflow import keras

from tensorflow.keras.utils import plot_model

def build_model():
    inputs = keras.layers.Input(shape=(28, 28, 1))
    conv1 = keras.layers.Conv2D(32, (3, 3), strides=1, activation='relu')(inputs)
    conv2 = keras.layers.Conv2D(64, (3, 3), strides=1, activation='relu')(conv1)
    maxpool1 = keras.layers.MaxPool2D((2, 2))(conv2)
    conv3 = keras.layers.Conv2D(64, (3, 3), strides=1, activation='relu')(maxpool1)
    conv4 = keras.layers.Conv2D(32, (3, 3), strides=1, activation='relu')(conv3)
    maxpool2 = keras.layers.MaxPool2D((2, 2))(conv4)
    flat = keras.layers.Flatten()(maxpool2)
    x1 = keras.layers.Dense(1024, activation='relu')(flat)
    x1 = keras.layers.Dropout(0.1)(x1)
    x = keras.layers.Concatenate(axis=1)([flat, x1])
    x2 = keras.layers.Dense(512, activation='relu')(x)
    x2 = keras.layers.Dropout(0.1)(x2)
    x = keras.layers.Concatenate(axis=1)([flat, x1, x2])
    x3 = keras.layers.Dense(256, activation='relu')(x)
    x3 = keras.layers.Dropout(0.1)(x3)
    x = keras.layers.Concatenate(axis=1)([flat, x1, x2, x3])
    x4 = keras.layers.Dense(128, activation='relu')(x)
    x4 = keras.layers.Dropout(0.1)(x4)
    x = keras.layers.Concatenate(axis=1)([flat, x1, x2, x3, x4])
    x = keras.layers.Dense(64, activation='relu')(x)
    x = keras.layers.Dense(10, activation='softmax')(x)
    model = keras.models.Model(inputs=inputs, outputs=x)
    model.compile(optimizer=keras.optimizers.Adam(learning_rate=0.001), loss=keras.losses.SparseCategoricalCrossentropy(), metrics=['accuracy'])
    return model

build_model().summary()
from tensorflow.keras.utils import plot_model
plot_model(build_model(), show_shapes=True)