[tensorflow]从Keras加载、保存模型、显示模型权重

import tensorflow as tf

构建模型,并加载imagenet预训练权重

base_model = tf.keras.applications.InceptionV3(include_top=False,weights='imagenet')

保存模型到本地./module/InceptionV3

tf.saved_model.save(base_model,'./module/InceptionV3')

加载本地模型-方式1

base_model = tf.keras.applications.InceptionV3(include_top=False,weights='./module/InceptionV3')

加载本地模型-方式2

base_model = tf.keras.applications.InceptionV3(include_top=False)
base_model.load_weights('./module/InceptionV3')

显示模型的结构和参数

base_model.summary()

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/condom10010/article/details/129410641