最近想使用DenseNet做特征提取,但是不知道DenseNet具体结构,所以做了一下DenseNet结构可视化。

# -*- coding: utf-8 -*-
"""
Created on Tue Feb 19 13:35:11 2019

@author: 13260
"""

from keras.applications.densenet import DenseNet201,preprocess_input
from keras.models import Model,load_model
import numpy as np
from keras.layers import Dense, GlobalAveragePooling2D
from keras.preprocessing import image
#base_model = DenseNet(weights='imagenet', include_top=False)
base_model = DenseNet201(weights='imagenet', include_top=False)
#base_model = load_model("F:/python/python-GenerRec/src/1019Resnet_gener_model_weights.h5")
#base_model.get_layer()
model = Model(inputs=base_model.input, outputs=base_model.output)
model.summary()
print('the number of layers in this model:'+str(len(model.layers)))

代码运行结果如图:

keras查看网络结构