def test_resample_feature_map(self): feat = tf.random.uniform([1, 16, 16, 320]) for apply_bn in [True, False]: for is_training in [True, False]: for strategy in ['tpu', '']: with self.subTest(apply_bn=apply_bn, is_training=is_training, strategy=strategy): tf.random.set_random_seed(SEED) expect_result = legacy_arch.resample_feature_map( feat, name='resample_p0', target_height=8, target_width=8, target_num_channels=64, apply_bn=apply_bn, is_training=is_training, strategy=strategy) tf.random.set_random_seed(SEED) resample_layer = efficientdet_arch_keras.ResampleFeatureMap( name='resample_p0', target_height=8, target_width=8, target_num_channels=64, apply_bn=apply_bn, is_training=is_training, strategy=strategy) actual_result = resample_layer(feat) self.assertAllCloseAccordingToType( expect_result, actual_result)
def test_resample_feature_map(self): feat = tf.random.uniform([1, 16, 16, 320]) for apply_fn in [True, False]: for is_training in [True, False]: for use_tpu in [True, False]: with self.subTest(apply_fn=apply_fn, is_training=is_training, use_tpu=use_tpu): tf.random.set_random_seed(111111) expect_result = efficientdet_arch.resample_feature_map( feat, name='resample_p0', target_height=8, target_width=8, target_num_channels=64, apply_bn=apply_fn, is_training=is_training, use_tpu=use_tpu) tf.random.set_random_seed(111111) actual_result = efficientdet_arch_keras.ResampleFeatureMap( name='resample_p0', target_height=8, target_width=8, target_num_channels=64, apply_bn=apply_fn, is_training=is_training, use_tpu=use_tpu)(feat) self.assertAllCloseAccordingToType( expect_result, actual_result)
def test_name(self): feat = tf.random.uniform([1, 16, 16, 320]) actual_result = efficientdet_arch_keras.ResampleFeatureMap( name='p0', target_height=8, target_width=8, target_num_channels=64)(feat) self.assertEqual("resample_p0/max_pooling2d/MaxPool:0", actual_result.name)
def test_op_name(self): with tf.Graph().as_default(): feat = tf.random.uniform([1, 16, 16, 320]) resample_layer = efficientdet_arch_keras.ResampleFeatureMap( name='p0', target_height=8, target_width=8, target_num_channels=64) result = resample_layer(feat) self.assertEqual('resample_p0/max_pooling2d/MaxPool:0', result.name)
def test_var_names(self): with tf.Graph().as_default(): feat = tf.random.uniform([1, 16, 16, 320]) resample_layer = efficientdet_arch_keras.ResampleFeatureMap( name='resample_p0', target_height=8, target_width=8, target_num_channels=64) resample_layer(feat) vars1 = [var.name for var in tf.trainable_variables()] with tf.Graph().as_default(): feat = tf.random.uniform([1, 16, 16, 320]) legacy_arch.resample_feature_map(feat, name='p0', target_height=8, target_width=8, target_num_channels=64) vars2 = [var.name for var in tf.trainable_variables()] self.assertEqual(vars1, vars2)