Example #1
0
 def testBuildPreLogitsLargeModel(self):
     batch_size = 5
     height, width = 331, 331
     num_classes = None
     inputs = tf.random_uniform((batch_size, height, width, 3))
     tf.train.create_global_step()
     with slim.arg_scope(nasnet.nasnet_large_arg_scope()):
         net, end_points = nasnet.build_nasnet_large(inputs, num_classes)
     self.assertNotIn('AuxLogits', end_points)
     self.assertNotIn('Predictions', end_points)
     self.assertTrue(net.op.name.startswith('final_layer/Mean'))
     self.assertListEqual(net.get_shape().as_list(), [batch_size, 4032])
Example #2
0
 def testBuildLogitsLargeModel(self):
     batch_size = 5
     height, width = 331, 331
     num_classes = 1000
     inputs = tf.random_uniform((batch_size, height, width, 3))
     tf.train.create_global_step()
     with slim.arg_scope(nasnet.nasnet_large_arg_scope()):
         logits, end_points = nasnet.build_nasnet_large(inputs, num_classes)
     auxlogits = end_points['AuxLogits']
     predictions = end_points['Predictions']
     self.assertListEqual(auxlogits.get_shape().as_list(),
                          [batch_size, num_classes])
     self.assertListEqual(logits.get_shape().as_list(),
                          [batch_size, num_classes])
     self.assertListEqual(predictions.get_shape().as_list(),
                          [batch_size, num_classes])
Example #3
0
 def testAllEndPointsShapesLargeModel(self):
     batch_size = 5
     height, width = 331, 331
     num_classes = 1000
     inputs = tf.random_uniform((batch_size, height, width, 3))
     tf.train.create_global_step()
     with slim.arg_scope(nasnet.nasnet_large_arg_scope()):
         _, end_points = nasnet.build_nasnet_large(inputs, num_classes)
     endpoints_shapes = {
         'Stem': [batch_size, 42, 42, 336],
         'Cell_0': [batch_size, 42, 42, 1008],
         'Cell_1': [batch_size, 42, 42, 1008],
         'Cell_2': [batch_size, 42, 42, 1008],
         'Cell_3': [batch_size, 42, 42, 1008],
         'Cell_4': [batch_size, 42, 42, 1008],
         'Cell_5': [batch_size, 42, 42, 1008],
         'Cell_6': [batch_size, 21, 21, 2016],
         'Cell_7': [batch_size, 21, 21, 2016],
         'Cell_8': [batch_size, 21, 21, 2016],
         'Cell_9': [batch_size, 21, 21, 2016],
         'Cell_10': [batch_size, 21, 21, 2016],
         'Cell_11': [batch_size, 21, 21, 2016],
         'Cell_12': [batch_size, 11, 11, 4032],
         'Cell_13': [batch_size, 11, 11, 4032],
         'Cell_14': [batch_size, 11, 11, 4032],
         'Cell_15': [batch_size, 11, 11, 4032],
         'Cell_16': [batch_size, 11, 11, 4032],
         'Cell_17': [batch_size, 11, 11, 4032],
         'Reduction_Cell_0': [batch_size, 21, 21, 1344],
         'Reduction_Cell_1': [batch_size, 11, 11, 2688],
         'global_pool': [batch_size, 4032],
         # Logits and predictions
         'AuxLogits': [batch_size, num_classes],
         'Logits': [batch_size, num_classes],
         'Predictions': [batch_size, num_classes]
     }
     self.assertCountEqual(endpoints_shapes.keys(), end_points.keys())
     for endpoint_name in endpoints_shapes:
         tf.logging.info('Endpoint name: {}'.format(endpoint_name))
         expected_shape = endpoints_shapes[endpoint_name]
         self.assertIn(endpoint_name, end_points)
         self.assertListEqual(
             end_points[endpoint_name].get_shape().as_list(),
             expected_shape)