def _conv(self, inputs, filters, kernel_size = 1, strides = 1, pad = 'VALID', name = 'conv'):
""" Spatial Convolution (CONV2D)
Args:
inputs : Input Tensor (Data Type : NHWC)
filters : Number of filters (channels)
kernel_size : Size of kernel
strides : Stride
pad : Padding Type (VALID/SAME) # DO NOT USE 'SAME' NETWORK BUILT FOR VALID
name : Name of the block
Returns:
conv : Output Tensor (Convolved Input)
"""
with tf.name_scope(name):
# Kernel for convolution, Xavier Initialisation
kernel = tf.Variable(tf.contrib.layers.xavier_initializer(uniform=False)([kernel_size,kernel_size, inputs.get_shape().as_list()[3], filters]), name= 'weights')
conv = tf.nn.conv2d(inputs, kernel, [1,strides,strides,1], padding=pad, data_format='NHWC')
if self.w_summary:
with tf.device('/cpu:0'):
tf.summary.histogram('weights_summary', kernel, collections = ['weight'])
return conv
评论列表
文章目录