def testBuildClassificationNetwork(self): batch_size = 5 num_frames = 64 height, width = 224, 224 num_classes = 1000 inputs = tf.random_uniform((batch_size, num_frames, height, width, 3)) logits, end_points = i3d.i3d(inputs, num_classes) self.assertTrue(logits.op.name.startswith('InceptionV1/Logits')) self.assertListEqual(logits.get_shape().as_list(), [batch_size, num_classes]) self.assertTrue('Predictions' in end_points) self.assertListEqual(end_points['Predictions'].get_shape().as_list(), [batch_size, num_classes])
def testEvaluation(self): batch_size = 2 num_frames = 64 height, width = 224, 224 num_classes = 1000 eval_inputs = tf.random_uniform( (batch_size, num_frames, height, width, 3)) logits, _ = i3d.i3d(eval_inputs, num_classes, is_training=False) predictions = tf.argmax(logits, 1) with self.test_session() as sess: sess.run(tf.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (batch_size, ))
def testEvaluation(self): batch_size = 2 num_frames = 64 height, width = 224, 224 num_classes = 1000 eval_inputs = tf.random_uniform((batch_size, num_frames, height, width, 3)) logits, _ = i3d.i3d(eval_inputs, num_classes, is_training=False) predictions = tf.argmax(logits, 1) with self.test_session() as sess: sess.run(tf.global_variables_initializer()) output = sess.run(predictions) self.assertEquals(output.shape, (batch_size,))
# tensorboard directory where the summaries are saved during training tb_dir = get_output_tb_dir(imdb, args.tag) print('TensorFlow summaries will be saved to `{:s}`'.format(tb_dir)) # also add the validation set, but with no flipping images orgflip = cfg.TRAIN.USE_FLIPPED cfg.TRAIN.USE_FLIPPED = False _, valroidb = combined_roidb(args.imdbval_name) print('{:d} validation roidb entries'.format(len(valroidb))) cfg.TRAIN.USE_FLIPPED = orgflip # load network if args.net == 'vgg16': # net = vgg16() net = i3d() elif args.net == 'res50': net = resnetv1(num_layers=50) elif args.net == 'res101': net = resnetv1(num_layers=101) elif args.net == 'res152': net = resnetv1(num_layers=152) elif args.net == 'mobile': net = mobilenetv1() else: raise NotImplementedError print(output_dir) train_net(net, imdb, roidb, valroidb,