Exemple #1
0
 def convfn(x, hparams):
     return common_layers.subseparable_conv(
         x,
         hparams.hidden_size // div, (kw, kh),
         padding="SAME",
         separability=sep,
         name="conv_%d%d_sep%d_div%d" % (kw, kh, sep, div))
 def testSubSeparableConv(self):
   for sep in [0, 1, 2, 4]:
     x = np.random.rand(5, 7, 1, 12)
     with self.test_session() as session:
       with tf.variable_scope("sep_%d" % sep):
         y = common_layers.subseparable_conv(
             tf.constant(x, dtype=tf.float32), 16, (3, 3), separability=sep)
       session.run(tf.global_variables_initializer())
       res = session.run(y)
     self.assertEqual(res.shape, (5, 5, 1, 16))
 def testSubSeparableConv(self):
     for sep in [0, 1, 2, 4]:
         x = np.random.rand(5, 7, 1, 12)
         with self.test_session() as session:
             with tf.variable_scope("sep_%d" % sep):
                 y = common_layers.subseparable_conv(tf.constant(
                     x, dtype=tf.float32),
                                                     16, (3, 1),
                                                     separability=sep)
             session.run(tf.global_variables_initializer())
             res = session.run(y)
         self.assertEqual(res.shape, (5, 5, 1, 16))