可视化创建的深度学习模型

2021-09-22  本文已影响0人  LabVIEW_Python

深度学习模型创建好后,有几种方式可以可视化

from tensorflow import keras
from tensorflow.keras import layers
#定义各层
input = keras.Input(shape=(32,32,3),name='img')
x = layers.Conv2D(32,3,activation='relu')(input)
x = layers.Conv2D(64,3,activation='relu')(x)
block_1_output = layers.MaxPooling2D(3)(x)

x = layers.Conv2D(64,3,activation='relu', padding='same')(block_1_output)
x = layers.Conv2D(64,3,activation='relu', padding='same')(x)
block_2_output = layers.add([x,block_1_output])

x = layers.Conv2D(64,3,activation='relu', padding='same')(block_2_output)
x = layers.Conv2D(64,3,activation='relu', padding='same')(x)
block_3_output = layers.add([x,block_2_output])

x = layers.Conv2D(64,3,activation='relu')(block_3_output)
x = layers.GlobalAveragePooling2D()(x)
x = layers.Dense(256, activation='relu')(x)
x = layers.Dropout(0.5)(x)
output = layers.Dense(10,name='classification_out')(x)
# 创建模型
model = keras.Model(input, output, name="alex_resnet")
# 查看模型摘要
model.summary()
# 绘制模型图
keras.utils.plot_model(model,"alex_resnet.png",show_shapes=True)
# 保存成.h5文件,用netron查看
model.save("alex_resnet.h5")
alex_resnet.png
alex_resnet_netron.png
上一篇下一篇

猜你喜欢

热点阅读