Python tensorflow.contrib.slim.nets.resnet_v1.resnet_arg_scope() Examples
The following are 11
code examples of tensorflow.contrib.slim.nets.resnet_v1.resnet_arg_scope().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
tensorflow.contrib.slim.nets.resnet_v1
, or try the search function
.
Example #1
Source File: resnet_v1.py From tf-imagenet with Apache License 2.0 | 6 votes |
def forward(self, inputs, num_classes, data_format, is_training): sc = resnet_arg_scope( weight_decay=0.0001, data_format=data_format, batch_norm_decay=0.997, batch_norm_epsilon=1e-5, batch_norm_scale=True, activation_fn=tf.nn.relu, use_batch_norm=True, is_training=is_training) with slim.arg_scope(sc): logits, end_points = resnet_v1_50( inputs, num_classes=num_classes, is_training=is_training, global_pool=True, output_stride=None, reuse=None, scope=self.scope) return logits, end_points
Example #2
Source File: resnet_v1.py From tf-imagenet with Apache License 2.0 | 6 votes |
def forward(self, inputs, num_classes, data_format, is_training): sc = resnet_arg_scope( weight_decay=0.0001, data_format=data_format, batch_norm_decay=0.997, batch_norm_epsilon=1e-5, batch_norm_scale=True, activation_fn=tf.nn.relu, use_batch_norm=True, is_training=is_training) with slim.arg_scope(sc): logits, end_points = resnet_v1_101( inputs, num_classes=num_classes, is_training=is_training, global_pool=True, output_stride=None, reuse=None, scope=self.scope) return logits, end_points
Example #3
Source File: resnet_v1.py From tf-imagenet with Apache License 2.0 | 6 votes |
def forward(self, inputs, num_classes, data_format, is_training): sc = resnet_arg_scope( weight_decay=0.0001, data_format=data_format, batch_norm_decay=0.997, batch_norm_epsilon=1e-5, batch_norm_scale=True, activation_fn=tf.nn.relu, use_batch_norm=True, is_training=is_training) with slim.arg_scope(sc): logits, end_points = resnet_v1_152( inputs, num_classes=num_classes, is_training=is_training, global_pool=True, output_stride=None, reuse=None, scope=self.scope) return logits, end_points # =========================================================================== # # Functional definition. # =========================================================================== #
Example #4
Source File: test_gradcam_dangling.py From darkon with Apache License 2.0 | 6 votes |
def setUp(self): tf.reset_default_graph() self.nbclasses = 1000 inputs = tf.placeholder(tf.float32, [1, 224, 224, 3]) with slim.arg_scope(resnet_v1.resnet_arg_scope()): net, end_points = resnet_v1.resnet_v1_50(inputs, self.nbclasses, is_training=False) saver = tf.train.Saver(tf.global_variables()) check_point = 'test/data/resnet_v1_50.ckpt' sess = tf.InteractiveSession() saver.restore(sess, check_point) conv_name = 'resnet_v1_50/block4/unit_3/bottleneck_v1/Relu' self.graph_origin = tf.get_default_graph().as_graph_def() self.insp = darkon.Gradcam(inputs, self.nbclasses, conv_name) self.sess = sess
Example #5
Source File: pose_netmulti.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
def extract_features(self, inputs): net_fun = net_funcs[self.cfg.net_type] mean = tf.constant( self.cfg.mean_pixel, dtype=tf.float32, shape=[1, 1, 1, 3], name="img_mean" ) im_centered = inputs - mean # The next part of the code depends upon which tensorflow version you have. vers = tf.__version__ vers = vers.split( "." ) # Updated based on https://github.com/AlexEMG/DeepLabCut/issues/44 if int(vers[0]) == 1 and int(vers[1]) < 4: # check if lower than version 1.4. with slim.arg_scope(resnet_v1.resnet_arg_scope(False)): net, end_points = net_fun( im_centered, global_pool=False, output_stride=16 ) else: with slim.arg_scope(resnet_v1.resnet_arg_scope()): net, end_points = net_fun( im_centered, global_pool=False, output_stride=16, is_training=False ) return net, end_points
Example #6
Source File: pose_net.py From DeepLabCut with GNU Lesser General Public License v3.0 | 6 votes |
def extract_features(self, inputs): net_fun = net_funcs[self.cfg.net_type] mean = tf.constant( self.cfg.mean_pixel, dtype=tf.float32, shape=[1, 1, 1, 3], name="img_mean" ) im_centered = inputs - mean # The next part of the code depends upon which tensorflow version you have. vers = tf.__version__ vers = vers.split( "." ) # Updated based on https://github.com/AlexEMG/DeepLabCut/issues/44 if int(vers[0]) == 1 and int(vers[1]) < 4: # check if lower than version 1.4. with slim.arg_scope(resnet_v1.resnet_arg_scope(False)): net, end_points = net_fun( im_centered, global_pool=False, output_stride=16 ) else: with slim.arg_scope(resnet_v1.resnet_arg_scope()): net, end_points = net_fun( im_centered, global_pool=False, output_stride=16, is_training=False ) return net, end_points
Example #7
Source File: resnet_v1.py From snmn with BSD 2-Clause "Simplified" License | 6 votes |
def resnet_v1_101_c4(inputs, is_training, reuse=None, scope='resnet_v1_101'): """ ResNet-101 model of [1]. See resnet_v1() for arg and return description. """ with slim.arg_scope(resnet_arg_scope()): blocks = [ resnet_v1_block('block1', base_depth=64, num_units=3, stride=2), resnet_v1_block('block2', base_depth=128, num_units=4, stride=2), # Use stride = 1 to extract 14 x 14 feature. The stride is applied # in the last unit of the block, followed by 1x1 convolution, so # changing the stride to 2 only makes the sampling denser. resnet_v1_block('block3', base_depth=256, num_units=23, stride=1), ] net, _ = resnet_v1( inputs, blocks, num_classes=None, is_training=is_training, global_pool=False, output_stride=None, include_root_block=True, spatial_squeeze=True, reuse=reuse, scope=scope) return net
Example #8
Source File: resnet_v1.py From snmn with BSD 2-Clause "Simplified" License | 6 votes |
def resnet_v1_152_c5(inputs, is_training, reuse=None, scope='resnet_v1_152'): """ ResNet-152 model of [1]. See resnet_v1() for arg and return description. """ with slim.arg_scope(resnet_arg_scope()): blocks = [ resnet_v1_block('block1', base_depth=64, num_units=3, stride=2), resnet_v1_block('block2', base_depth=128, num_units=8, stride=2), resnet_v1_block('block3', base_depth=256, num_units=36, stride=2), resnet_v1_block('block4', base_depth=512, num_units=3, stride=1), ] net, _ = resnet_v1( inputs, blocks, num_classes=None, is_training=is_training, global_pool=False, output_stride=None, include_root_block=True, spatial_squeeze=True, reuse=reuse, scope=scope) return net
Example #9
Source File: det_lesion.py From liverseg-2017-nipsws with MIT License | 6 votes |
def det_lesion_resnet(inputs, is_training_option=False, scope='det_lesion'): """Defines the network Args: inputs: Tensorflow placeholder that contains the input image scope: Scope name for the network Returns: net: Output Tensor of the network end_points: Dictionary with all Tensors of the network """ with tf.variable_scope(scope, 'det_lesion', [inputs]) as sc: end_points_collection = sc.name + '_end_points' with slim.arg_scope(resnet_v1.resnet_arg_scope()): net, end_points = resnet_v1.resnet_v1_50(inputs, is_training=is_training_option) net = slim.flatten(net, scope='flatten5') net = slim.fully_connected(net, 1, activation_fn=tf.nn.sigmoid, weights_initializer=initializers.xavier_initializer(), scope='output') utils.collect_named_outputs(end_points_collection, 'det_lesion/output', net) end_points = slim.utils.convert_collection_to_dict(end_points_collection) return net, end_points
Example #10
Source File: test_gradcam.py From darkon with Apache License 2.0 | 5 votes |
def test_resnet(self): with slim.arg_scope(resnet_v1.resnet_arg_scope()): net, end_points = resnet_v1.resnet_v1_50(self.inputs, self.nbclasses, is_training=False) saver = tf.train.Saver(tf.global_variables()) check_point = 'test/data/resnet_v1_50.ckpt' sess = tf.InteractiveSession() saver.restore(sess, check_point) self.sess = sess self.graph_origin = tf.get_default_graph() self.target_op_name = darkon.Gradcam.candidate_featuremap_op_names(sess, self.graph_origin)[-1] self.model_name = 'resnet' self.assertEqual('resnet_v1_50/block4/unit_3/bottleneck_v1/Relu', self.target_op_name)
Example #11
Source File: saliency-maps.py From tensorpack with Apache License 2.0 | 5 votes |
def build_graph(self, orig_image): mean = tf.get_variable('resnet_v1_50/mean_rgb', shape=[3]) with guided_relu(): with slim.arg_scope(resnet_v1.resnet_arg_scope()): image = tf.expand_dims(orig_image - mean, 0) logits, _ = resnet_v1.resnet_v1_50(image, 1000, is_training=False) saliency_map(logits, orig_image, name="saliency")