还是一样用tensorflow实现了一下VGG16的网络结构。
import tensorflow as tf
learn_rate=1e-3
batch_size=50
train_epoch=10000
x=tf.placeholder(tf.float32,shape=[None,224*224],name='x')
y=tf.placeholder(tf.float32,shape=[None,10],name='y')
def get_variable(name,shape=None,dtype=tf.float32,initialiezr=tf.truncated_normal_initializer(mean=0,stddev=0.1)):
return tf.get_variable(name,shape,dtype,initialiezr)
def VGG16(x,y):
with tf.variable_scope('input'):
net=tf.reshape(x,[-1,224,224,3])
with tf.variable_scope('conv1'):
net=tf.nn.conv2d(input=net,filter=get_variable('w',[3,3,3,64]),strides=[1,1,1,1],padding='SAME')
net=tf.nn.bias_add(net,get_variable('b',[64]))
net=tf.nn.relu(net)
net=tf.nn.conv2d(input=net,filter=get_variable('w',[3,3,64,64])