得到数据之后,接下来就是网络的搭建,我在这里将模型单独定义出来,方便后期的网络修正。
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
filename:DR_alexnet.py
creat time:2018年1月16日
author:huangxudong
"""
import tensorflow as tf
import numpy as np
#define different layer function
def maxPoolLayer(x,kHeight,kWidth,strideX,strideY,name,padding="SAME"):
return tf.nn.max_pool(x,ksize=[1,kHeight,kWidth,1],strides=[1,strideX,strideY,1],padding=padding,name=name)
def dropout(x,keepPro,name=None):
return tf.nn.dropout(x,keepPro,name)
def LRN(x,R,alpha,beta,name=None,bias=1.0): #局部相应归一化
return tf.nn.local_response_normalization(x,depth_radius=R,alpha=alpha,
beta=beta,bias=bias,name=name)
def fcLayer(x,inputD,outputD,reluFlag,name):
with tf.variable_scope