def resnet_v2_50(inputs, config, is_training=True, scope='resnet_v2_50'): """Modified ResNet-50 model.""" blocks = [ resnet_v2.resnet_v2_block('block1', base_depth=config.block1_depth, num_units=config.block1_units, stride=config.block1_stride), resnet_v2.resnet_v2_block('block2', base_depth=config.block2_depth, num_units=config.block2_units, stride=config.block2_stride), resnet_v2.resnet_v2_block('block3', base_depth=config.block3_depth, num_units=config.block3_units, stride=config.block3_stride), resnet_v2.resnet_v2_block('block4', base_depth=config.block4_depth, num_units=config.block4_units, stride=config.block4_stride), ] return resnet_v2.resnet_v2(inputs, blocks, is_training=is_training, global_pool=False, include_root_block=True, scope=scope)
def resnet_12(inputs, num_classes, scope='resnet_12'): blocks = [ resnet_v2.resnet_v2_block('block1', base_depth=64, num_units=2, stride=1), resnet_v2.resnet_v2_block('block2', base_depth=64, num_units=2, stride=1), resnet_v2.resnet_v2_block('block3', base_depth=64, num_units=2, stride=1), resnet_v2.resnet_v2_block('block4', base_depth=64, num_units=2, stride=1), resnet_v2.resnet_v2_block('block5', base_depth=64, num_units=2, stride=1) ] return resnet_v2.resnet_v2(inputs, blocks, num_classes, is_training=True, global_pool=True, output_stride=None, include_root_block=True, reuse=None, scope=scope)
def resnet_small(inputs, num_classes=None, is_training=True, global_pool=True, output_stride=None, include_root_block=True, reuse=None, scope='resnet_small'): blocks = [ resnet_v2.resnet_v2_block('block1', base_depth=32, num_units=2, stride=2), resnet_v2.resnet_v2_block('block2', base_depth=64, num_units=2, stride=2), resnet_v2.resnet_v2_block('block3', base_depth=128, num_units=2, stride=2), resnet_v2.resnet_v2_block('block4', base_depth=256, num_units=2, stride=2), ] return resnet_v2.resnet_v2(inputs, blocks, num_classes, is_training=is_training, global_pool=global_pool, output_stride=output_stride, include_root_block=include_root_block, reuse=reuse, scope=scope)
def fr_v2(x, output_neurons, inside_neurons, is_training, name='fr', wt_decay=0.0001, stride=1, updates_collections=tf.GraphKeys.UPDATE_OPS): """Performs fusion of information between the map and the reward map. Inputs x: NxHxWxC1 Outputs fr map: NxHxWx(output_neurons) """ if type(stride) != list: stride = [stride] with slim.arg_scope( resnet_v2.resnet_utils.resnet_arg_scope(weight_decay=wt_decay)): with slim.arg_scope([slim.batch_norm], updates_collections=updates_collections) as arg_sc: # Change the updates_collections for the conv normalizer_params to None for i in range(len(arg_sc.keys())): if 'convolution' in arg_sc.keys()[i]: arg_sc.values()[i]['normalizer_params'][ 'updates_collections'] = updates_collections with slim.arg_scope(arg_sc): bottleneck = resnet_v2.bottleneck blocks = [] for i, s in enumerate(stride): b = resnet_v2.resnet_utils.Block( 'block{:d}'.format(i + 1), bottleneck, [{ 'depth': output_neurons, 'depth_bottleneck': inside_neurons, 'stride': stride[i] }]) blocks.append(b) x, outs = resnet_v2.resnet_v2(x, blocks, num_classes=None, is_training=is_training, global_pool=False, output_stride=None, include_root_block=False, reuse=False, scope=name) return x, outs
def _resnet_small(self, inputs, num_classes=None, global_pool=True, output_stride=None, include_root_block=True, reuse=None, scope='resnet_v2_small'): """A shallow and thin ResNet v2 for faster tests.""" bottleneck = resnet_v2.bottleneck blocks = [ resnet_utils.Block( 'block1', bottleneck, [(4, 1, 1)] * 2 + [(4, 1, 2)]), resnet_utils.Block( 'block2', bottleneck, [(8, 2, 1)] * 2 + [(8, 2, 2)]), resnet_utils.Block( 'block3', bottleneck, [(16, 4, 1)] * 2 + [(16, 4, 2)]), resnet_utils.Block( 'block4', bottleneck, [(32, 8, 1)] * 2)] return resnet_v2.resnet_v2(inputs, blocks, num_classes, global_pool, output_stride, include_root_block, reuse, scope)
def resnet_v2_light(inputs, num_classes=None, is_training=True, global_pool=True, output_stride=None, spatial_squeeze=True, reuse=None, scope='resnet_v2_light'): """ResNet-light model of AIlab. See resnet_v2() for arg and return description.""" blocks = [ resnet_v2.resnet_v2_block('block1', base_depth=16, num_units=3, stride=2), resnet_v2.resnet_v2_block('block2', base_depth=32, num_units=4, stride=2), resnet_v2.resnet_v2_block('block3', base_depth=64, num_units=8, stride=2), resnet_v2.resnet_v2_block('block4', base_depth=128, num_units=3, stride=1), ] return resnet_v2.resnet_v2(inputs, blocks, num_classes, is_training=is_training, global_pool=global_pool, output_stride=output_stride, include_root_block=True, reuse=reuse, scope=scope)