Пример #1
0
 def testPool(self):
     x = np.random.rand(5, 8, 1, 11)
     y = common_layers.pool(tf.constant(x, dtype=tf.float32), (2, 2), "AVG",
                            "SAME")
     self.evaluate(tf.global_variables_initializer())
     res = self.evaluate(y)
     self.assertEqual(res.shape, (5, 8, 1, 11))
Пример #2
0
 def testPool(self):
   x = np.random.rand(5, 8, 1, 11)
   y = common_layers.pool(
       tf.constant(x, dtype=tf.float32), (2, 2), "AVG", "SAME")
   self.evaluate(tf.global_variables_initializer())
   res = self.evaluate(y)
   self.assertEqual(res.shape, (5, 8, 1, 11))
Пример #3
0
 def testPool(self):
     x = np.random.rand(5, 8, 1, 11)
     with self.test_session() as session:
         y = common_layers.pool(tf.constant(x, dtype=tf.float32), (2, 2),
                                "AVG", "SAME")
         session.run(tf.global_variables_initializer())
         res = session.run(y)
     self.assertEqual(res.shape, (5, 8, 1, 11))
Пример #4
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 2))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 2),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")
Пример #5
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 2))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 2),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")
Пример #6
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     # We only stride along the length dimension to preserve the spectral
     # bins (which are tiny in dimensionality relative to length)
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 1))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 1),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")
Пример #7
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     # Typically audio samples are >100k samples in length and have a width
     # of 2 or 4. Mono audio has a single channel while stereo has 2.
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 2))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 2),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")
Пример #8
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     # We only stride along the length dimension to preserve the spectral
     # bins (which are tiny in dimensionality relative to length)
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 1))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 1),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")
Пример #9
0
 def xnet_resblock(x, filters, res_relu, name):
   with tf.variable_scope(name):
     # Typically audio samples are >100k samples in length and have a width
     # of 2 or 4. Mono audio has a single channel while stereo has 2.
     y = common_layers.separable_conv_block(
         x,
         filters, [((1, 1), (3, 3)), ((1, 1), (3, 3))],
         first_relu=True,
         padding="SAME",
         force2d=True,
         name="sep_conv_block")
     y = common_layers.pool(y, (3, 3), "MAX", "SAME", strides=(2, 2))
     return y + common_layers.conv_block(
         x,
         filters, [((1, 1), (1, 1))],
         padding="SAME",
         strides=(2, 2),
         first_relu=res_relu,
         force2d=True,
         name="res_conv0")