Visualizing Deep Learning Model Architecture
from tensorflow.keras.applications import ResNet50
from tensorflow.keras.models import Model
from tensorflow.keras.layers import Flatten, Dense, Dropout
from tensorflow.keras.utils import plot_model
# ResNet50 modelini yükleyelim
base_model = ResNet50(weights='imagenet', include_top=False, input_shape=(224, 224, 3))
num_classes = 3
# Yeni katmanları ekleyelim
x = base_model.output
x = Flatten()(x)
x = Dense(256, activation='relu')(x)
x = Dropout(0.5)(x)
x = Dense(128, activation='relu')(x)
x = Dense(64, activation='relu')(x)
predictions = Dense(num_classes, activation='softmax')(x) # num_classes, sınıf sayısına karşılık gelen bir değerdir
# Yeni modeli tanımlayalım
model = Model(inputs=base_model.input, outputs=predictions)
# Modelin görselleştirmesini yapalım
plot_model(model, to_file='model_plot.png', show_shapes=True, show_layer_names=True)
import visualkeras
visualkeras.layered_view(model, legend=True) # without custom font
from PIL import ImageFont
font = ImageFont.truetype("arial.ttf", 12)
visualkeras.layered_view(model, legend=True, font=font) # selected font

