visualkeras ResNetV2 example#
An example showing the visualkeras
function
used by a tf.keras.Model
model.
# Authors: The scikit-plots developers
# SPDX-License-Identifier: BSD-3-Clause
# Force garbage collection
import gc; gc.collect()
import tensorflow as tf
# Clear any session to reset the state of TensorFlow/Keras
tf.keras.backend.clear_session()
from scikitplot import visualkeras
model = tf.keras.applications.ResNet50V2(
include_top=True,
weights=None, # "imagenet" or 'path/'
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000,
classifier_activation="softmax",
name="resnet50v2",
)
img_resnet50v2 = visualkeras.layered_view(
model,
legend=True,
show_dimension=True,
to_file='../result_images/resnet50v2.png',
)
try:
import matplotlib.pyplot as plt
plt.imshow(img_resnet50v2)
plt.axis('off')
plt.show()
except:
pass
# model = tf.keras.applications.ResNet101V2(
# include_top=True,
# weights=None, # "imagenet" or 'path/'
# input_tensor=None,
# input_shape=None,
# pooling=None,
# classes=1000,
# classifier_activation="softmax",
# name="resnet101v2",
# )
# visualkeras.layered_view(
# model,
# legend=True,
# show_dimension=True,
# to_file='../result_images/resnet101v2.png',
# )
# model = tf.keras.applications.ResNet152V2(
# include_top=True,
# weights=None, # "imagenet" or 'path/'
# input_tensor=None,
# input_shape=None,
# pooling=None,
# classes=1000,
# classifier_activation="softmax",
# name="resnet152v2",
# )
# visualkeras.layered_view(
# model,
# legend=True,
# show_dimension=True,
# to_file='../result_images/resnet152v2.png',
# )
Total running time of the script: (0 minutes 5.348 seconds)
Related examples
visualkeras custom VGG example
visualkeras custom VGG example
visualkeras EfficientNetV2 example
visualkeras EfficientNetV2 example
visualkeras custom vgg16 show dimension example
visualkeras custom vgg16 show dimension example
visualkeras Spam Dense example
visualkeras Spam Dense example