python -keras:将两个模型合并为一个顺序
如何使用两个模型创建一个模型顺序? 我有两个模型,一个是一个KERAS应用程序(VGG16模型)和一个自定义模型,我想将它们合并为一个顺序模型。
我尝试以这种方式进行操作:
VGG16_model = tf.keras.applications.VGG16(
include_top=False,
weights='imagenet',
pooling='avg'
)
teacher = tf.keras.Sequential(
[
VGG16_model,
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation=('relu')),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(256, activation=('relu')),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation=('softmax'))
],
name = 'teacher',
)
但是当我打印模型的摘要时,我有这个东西: https://i.sstatic.net/xsktg.png
但是我想拥有我的总结VGG16型号的所有层,我该怎么做?
How do create one model sequential with two models?
I have two models, one a Keras application (vgg16 model) and a custom model and I would like to merge them into one sequential model.
I try to do it in this way :
VGG16_model = tf.keras.applications.VGG16(
include_top=False,
weights='imagenet',
pooling='avg'
)
teacher = tf.keras.Sequential(
[
VGG16_model,
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation=('relu')),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(256, activation=('relu')),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation=('softmax'))
],
name = 'teacher',
)
But when I print the summary of the model I have this thing :
https://i.sstatic.net/xSKTg.png
But I would like to have in my summary all the layers of the VGG16 model, how can I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样的事情:
Try something like this: