visualkeras: EfficientNetV2 example#

An example showing the visualkeras function used by a tf.keras.Model model.

 9 # Authors: The scikit-plots developers
10 # SPDX-License-Identifier: BSD-3-Clause

pip install protobuf==5.29.4

15 import tensorflow as tf
16
17 # Clear any session to reset the state of TensorFlow/Keras
18 tf.keras.backend.clear_session()
19
20 from scikitplot import visualkeras
23 model = tf.keras.applications.EfficientNetV2B0(
24     include_top=True,
25     weights=None,  # "imagenet" or 'path/'
26     input_tensor=None,
27     input_shape=None,
28     pooling=None,
29     classes=1000,
30     classifier_activation="softmax",
31     name="efficientnetv2-b0",
32 )
33 # model.summary()
36 img_efficientnetv2 = visualkeras.layered_view(
37     model,
38     legend=True,
39     min_z=1,
40     min_xy=1,
41     max_z=4096,
42     max_xy=4096,
43     scale_z=0.01,
44     scale_xy=10,
45     font={"font_size": 99},
46     # to_file="result_images/efficientnetv2-b0.png",
47     save_fig=True,
48     save_fig_filename="efficientnetv2-b0.png",
49 )
50 img_efficientnetv2
plot efficientnetv2
<matplotlib.image.AxesImage object at 0x7f4f043dc090>

Tags: model-type: classification model-workflow: model building plot-type: visualkeras domain: neural network level: beginner purpose: showcase

 63 # model = tf.keras.applications.EfficientNetV2B1(
 64 #     include_top=True,
 65 #     weights=None,  # "imagenet" or 'path/'
 66 #     input_tensor=None,
 67 #     input_shape=None,
 68 #     pooling=None,
 69 #     classes=1000,
 70 #     classifier_activation="softmax",
 71 #     name="efficientnetv2-b1",
 72 # )
 73 # visualkeras.layered_view(
 74 #   model,
 75 #   legend=True,
 76 #   show_dimension=True,
 77 #   to_file='result_images/efficientnetv2-b1.png',
 78 # )
 79
 80 # model = tf.keras.applications.EfficientNetV2B2(
 81 #     include_top=True,
 82 #     weights=None,  # "imagenet" or 'path/'
 83 #     input_tensor=None,
 84 #     input_shape=None,
 85 #     pooling=None,
 86 #     classes=1000,
 87 #     classifier_activation="softmax",
 88 #     name="efficientnetv2-b2",
 89 # )
 90 # visualkeras.layered_view(
 91 #   model,
 92 #   legend=True,
 93 #   show_dimension=True,
 94 #   to_file='result_images/efficientnetv2-b2.png',
 95 # )
 96
 97 # model = tf.keras.applications.EfficientNetV2B3(
 98 #     include_top=True,
 99 #     weights=None,  # "imagenet" or 'path/'
100 #     input_tensor=None,
101 #     input_shape=None,
102 #     pooling=None,
103 #     classes=1000,
104 #     classifier_activation="softmax",
105 #     name="efficientnetv2-b3",
106 # )
107 # visualkeras.layered_view(
108 #   model,
109 #   legend=True,
110 #   show_dimension=True,
111 #   to_file='result_images/efficientnetv2-b3.png',
112 # )
113
114 # model = tf.keras.applications.EfficientNetV2S(
115 #     include_top=True,
116 #     weights=None,  # "imagenet" or 'path/'
117 #     input_tensor=None,
118 #     input_shape=None,
119 #     pooling=None,
120 #     classes=1000,
121 #     classifier_activation="softmax",
122 #     name="efficientnetv2-s",
123 # )
124 # visualkeras.layered_view(
125 #   model,
126 #   legend=True,
127 #   show_dimension=True,
128 #   to_file='result_images/efficientnetv2-s.png',
129 # )
130
131 # model = tf.keras.applications.EfficientNetV2M(
132 #     include_top=True,
133 #     weights=None,  # "imagenet" or 'path/'
134 #     input_tensor=None,
135 #     input_shape=None,
136 #     pooling=None,
137 #     classes=1000,
138 #     classifier_activation="softmax",
139 #     name="efficientnetv2-m",
140 # )
141 # visualkeras.layered_view(
142 #   model,
143 #   legend=True,
144 #   show_dimension=True,
145 #   to_file='result_images/efficientnetv2-m.png',
146 # )
147
148 # model = tf.keras.applications.EfficientNetV2L(
149 #     include_top=True,
150 #     weights=None,  # "imagenet" or 'path/'
151 #     input_tensor=None,
152 #     input_shape=None,
153 #     pooling=None,
154 #     classes=1000,
155 #     classifier_activation="softmax",
156 #     name="efficientnetv2-l",
157 # )
158 # visualkeras.layered_view(
159 #   model,
160 #   legend=True,
161 #   show_dimension=True,
162 #   to_file='result_images/efficientnetv2-l.png',
163 # )

Total running time of the script: (0 minutes 5.064 seconds)

Related examples

visualkeras: ResNetV2 example

visualkeras: ResNetV2 example

visualkeras: custom VGG example

visualkeras: custom VGG example

visualkeras: custom vgg16 show dimension example

visualkeras: custom vgg16 show dimension example

plot_calibration with examples

plot_calibration with examples

Gallery generated by Sphinx-Gallery