Example #1
0
 def branch1(self, x, numOut, s):
     with tf.variable_scope("conv1"):
         conv1 = utils.relu(utils.Bn(utils.conv2d(x, numOut/4, d_h=s, d_w=s), training=self.is_training))
     with tf.variable_scope("conv2"):
         conv2 = utils.relu(utils.Bn(utils.conv2d(conv1, numOut/4, 3, 3), training=self.is_training))
     with tf.variable_scope("conv3"):
         conv3 = utils.Bn(utils.conv2d(conv2, numOut), training=self.is_training)
     return conv3
Example #2
0
 def inference(self, x):
     with tf.variable_scope("conv0"):
         conv1 = utils.relu(utils.Bn(utils.conv2d(x, 64, 7, 7, 2, 2, bias=True), training=self.is_training))
     with tf.name_scope("pool1"):
         pool1 = utils.max_pool(conv1, 3, 3, 2, 2)
     with tf.variable_scope("group0"):
         res2a = self.residual(pool1, 256, name='block0')
         res2b = self.residual(res2a, 256, name='block1')
         res2c = self.residual(res2b, 256, name='block2')
     with tf.variable_scope("group1"):
         res3a = self.residual(res2c, 512, 2, name='block0')
         res3b = self.residual(res3a, 512, name='block1')
         res3c = self.residual(res3b, 512, name='block2')
         res3d = self.residual(res3c, 512, name='block3')
     with tf.variable_scope("group2"):
         res4a = self.residual(res3d, 1024, 2, name='block0')
         res4b = self.residual(res4a, 1024, name='block1')
         res4c = self.residual(res4b, 1024, name='block2')
         res4d = self.residual(res4c, 1024, name='block3')
         res4e = self.residual(res4d, 1024, name='block4')
         res4f = self.residual(res4e, 1024, name='block5')
     with tf.variable_scope("group3"):
         res5a = self.residual(res4f, 2048, 2, name='block0')
         res5b = self.residual(res5a, 2048, name='block1')
         res5c = self.residual(res5b, 2048, name='block2')
     with tf.name_scope("pool5"):
         pool5 = utils.global_pool(res5c)
     with tf.variable_scope("linear"):
         dropout = tf.nn.dropout(pool5, keep_prob=self.keep_prob)
         out = utils.linear(dropout, 1000)
     return out
Example #3
0
 def inference(self, x, grah):
     with tf.variable_scope("conv0"):
         if self.res_name == "resnet50":
             net = utils.relu(
                 utils.Bn(utils.conv2d(x, 64, 7, 7, 2, 2, bias=True),
                          training=self.is_training))
         else:
             net = utils.relu(
                 utils.Bn(utils.conv2d(x, 64, 7, 7, 2, 2, bias=False),
                          training=self.is_training))
     with tf.name_scope("pool1"):
         net = utils.max_pool(net, 3, 3, 2, 2)
     with tf.variable_scope("group0"):
         for i in range(grah[0]):
             net = self.residual(net, 256, name='block' + str(i))
     with tf.variable_scope("group1"):
         for i in range(grah[1]):
             if i == 0:
                 net = self.residual(net, 512, 2, name='block' + str(i))
             else:
                 net = self.residual(net, 512, name='block' + str(i))
     with tf.variable_scope("group2"):
         for i in range(grah[2]):
             if i == 0:
                 net = self.residual(net, 1024, 2, name='block' + str(i))
             else:
                 net = self.residual(net, 1024, name='block' + str(i))
     with tf.variable_scope("group3"):
         for i in range(grah[3]):
             if i == 0:
                 net = self.residual(net, 2048, 2, name='block' + str(i))
             else:
                 net = self.residual(net, 2048, name='block' + str(i))
     with tf.name_scope("pool5"):
         net = utils.global_pool(net)
     with tf.variable_scope("linear"):
         net = tf.nn.dropout(net, keep_prob=self.keep_prob)
         net = utils.linear(net, 1000)
     return net
Example #4
0
 def inference(self, x):
     with tf.variable_scope("conv0"):
         conv1 = utils.relu(utils.Bn(utils.conv2d(x, 64, 7, 7, 2, 2, bias=False), training=self.is_training))
     with tf.name_scope("pool1"):
         pool1 = utils.max_pool(conv1, 3, 3, 2, 2)
     with tf.variable_scope("group0"):
         res2a = self.residual(pool1, 64, branch=True, name='block0')
         res2b = self.residual(res2a, 64, name='block1')
     with tf.variable_scope("group1"):
         res3a = self.residual(res2b, 128, 2, name='block0')
         res3b = self.residual(res3a, 128, name='block1')
     with tf.variable_scope("group2"):
         res4a = self.residual(res3b, 256, 2, name='block0')
         res4b = self.residual(res4a, 256, name='block1')
     with tf.variable_scope("group3"):
         res5a = self.residual(res4b, 512, 2, name='block0')
         res5b = self.residual(res5a, 512, name='block1')
     with tf.name_scope("pool5"):
         pool5 = utils.global_pool(res5b)
     with tf.variable_scope("linear"):
         dropout = tf.nn.dropout(pool5, keep_prob=self.keep_prob)
         out = utils.linear(dropout, 1000)
     return out
Example #5
0
 def branch2(self, x, numOut, s):
     with tf.variable_scope("convshortcut"):
         return utils.Bn(utils.conv2d(x, numOut, d_h=s, d_w=s),
                         training=self.is_training)