一、 VGG16简介
- VGG16网络是通过卷积和全连接的方式提取图片特征,进行识别一种网络结构。曾在某年取得分类第二,定位任务第一的佳绩。
- 其结构包含: 13个卷积层 + 3个全连接层,所以被称为VGG16,如下图绿色的部分即是网络的结构组成:
- 卷积配置说明:
- input(224224RGB image) :输入图片大小为:224224,通道数为:3
- conv3_XXX :卷积核为3(以下都是卷积核都是3,后面省略),卷积层的通道数为:XXX
- VGG16特点(这里是借鉴[韩鼎の个人网站]:
- 卷积核全部使用3*3的卷积核 ,且所有卷积核 : strides=[1,1,1,1] ,padding=“SAME”。
- 池化层全部使用: max的池化方式,2*2的池化核,通过全0填充,步长为2,strides=[1,2,2,1] ,padding=“SAME”。
二、代码实现
import h5py
import json
import tensorflow as tf
import cv2
import numpy as np
import matplotlib.pyplot as plt
model_path = './kreas_vgg16_model_para/vgg16_weights_tf_dim_ordering_tf_kernels.h5'
with h5py.File(model_path,'r') as f:
block1_conv1_W_1 = f['/block1_conv1/block1_conv1_W_1:0'][:]
block1_conv2_W_1 = f['/block1_conv2/block1_conv2_W_1:0'][:]
block1_conv1_b_1 = f['/block1_conv1/block1_conv1_b_1:0'][:]
block1_conv2_b_1 = f['/block1_conv2/block1_conv2_b_1:0'][:]
block2_conv1_W_1 = f['/block2_conv1/block2_conv1_W_1:0'][:]
block2_conv2_W_1 = f['/block2_conv2/block2_conv2_W_1:0'][:]
block2_conv1_b_1 = f['/block2_conv1/block2_conv1_b_1:0'][:]
block2_conv2_b_1 = f['/block2_conv2/block2_conv2_b_1:0'][:]
block3_conv1_W_1 = f['/block3_conv1/block3_conv1_W_1:0'][:]
block3_conv2_W_1 = f['/block3_conv2/block3_conv2_W_1:0'][:]
block3_conv3_W_1 = f['/block3_conv3/block3_conv3_W_1:0'][:]
block3_conv1_b_1 = f['/block3_conv1/block3_conv1_b_1:0'][:]
block3_conv2_b_1 = f['/block3_conv2/block3_conv2_b_1:0'][:]
block3_conv3_b_1 = f['/block3_conv3/block3_conv3_b_1:0'][:]
block4_conv1_W_1 = f['/block4_conv1/block4_conv1_W_1:0']