normalizer_fn=None, scope='logits' )
size = tf.shape ( inputs ) [ 1:3 ]
# resize the output logits to match the labels dimensions
# net = tf.image.resize_nearest_neighbor ( net, size )
net = tf.image.resize_bilinear ( net, size )
return net
为了实现残差网络 block4 中具有多重网格的空洞卷积,我们仅仅改变了 resnet_utils.py 文件中的以下这段代码:
...
with tf.variable_scope ( 'unit_%d' % ( i + 1 ) , values= [ net ] ) :
# If we have reached the target output_stride, then we need to employ
# atrous convolution with stride=1 and multiply the atrous rate by the
# current unit's stride for use in subsequent layers.
if output_stride is not None and current_stride == output_stride:
# Only uses atrous convolutions with multi-graid rates in the last ( block4 ) block
if block.scope == "block4":
net = block.unit_fn ( net, rate=rate * multi_grid [ i ] , **dict ( unit, stride=1 ) )
else:
net = block.unit_fn ( net, rate=rate, **dict ( unit, stride=1 ) )
rate *= unit.get ( 'stride', 1 )
训练
为了训练网络,我们决定使用来自于《Semantic contours from inverse detectors》的扩增版的 Pascal VOC 数据集。