def resnet_v1_200(inputs, num_classes=None, is_training=True, global_pool=True, output_stride=None, reuse=None, scope='resnet_v1_200'): """ResNet-200 model of [2]. See resnet_v1() for arg and return description.""" blocks = [ resnet_utils.Block('block1', bottleneck, [(256, 64, 1)] * 2 + [(256, 64, 2)]), resnet_utils.Block('block2', bottleneck, [(512, 128, 1)] * 23 + [(512, 128, 2)]), resnet_utils.Block('block3', bottleneck, [(1024, 256, 1)] * 35 + [(1024, 256, 2)]), resnet_utils.Block('block4', bottleneck, [(2048, 512, 1)] * 3) ] return resnet_v1(inputs, blocks, num_classes, is_training, global_pool=global_pool, output_stride=output_stride, include_root_block=True, reuse=reuse, scope=scope)
def create_trunk(self, images, global_pool=True): red, green, blue = tf.split(images * 255, 3, axis=3) images = tf.concat([blue, green, red], 3) - MEAN_COLOR with slim.arg_scope( resnet_v1.resnet_arg_scope(is_training=self.training, weight_decay=self.weight_decay, batch_norm_decay=args.bn_decay)): blocks = [ resnet_utils.Block('block1', bottleneck, [(256, 64, 1)] * 3), resnet_utils.Block('block2', bottleneck, [(512, 128, 2)] + [(512, 128, 1)] * 3), resnet_utils.Block('block3', bottleneck, [(1024, 256, 2)] + [(1024, 256, 1)] * self.num_block3), resnet_utils.Block('block4', bottleneck, [(2048, 512, 2)] + [(2048, 512, 1)] * 2) ] net, endpoints = resnet_v1.resnet_v1(images, blocks, global_pool=global_pool, reuse=self.reuse, scope=self.scope) self.outputs = endpoints
def resnet_v2_block(scope, base_depth, num_units, stride): """ Helper function for creating a resnet_v2 bottleneck block. :param scope: The scope of the block. :param base_depth: The depth of the bottleneck layer for each unit. :param num_units: The number of units in the block. :param stride: The stride of the block, implemented as a stride in the last unit. All other units have stride=1. :return: A resnet_v2 bottleneck block. """ return resnet_utils.Block(scope, bottleneck, [{ 'depth': base_depth * 4, 'depth_bottleneck': base_depth, 'stride': 1 }] * (num_units - 1) + [{ 'depth': base_depth * 4, 'depth_bottleneck': base_depth, 'stride': stride }])
def resnet_v2_block(scope, base_depth, num_units, stride, centered_stride=False): """Helper function for creating a resnet_v2 bottleneck block. Args: scope: The scope of the block. base_depth: The depth of the bottleneck layer for each unit. num_units: The number of units in the block. stride: The stride of the block, implemented as a stride in the last unit. All other units have stride=1. Returns: A resnet_v2 bottleneck block. """ return resnet_utils.Block(scope, bottleneck, [{ 'depth': base_depth * 4, 'depth_bottleneck': base_depth, 'stride': 1, }] * (num_units - 1) + [{ 'depth': base_depth * 4, 'depth_bottleneck': base_depth, 'stride': stride, 'centered_stride': centered_stride, }])