Exemple #1
0
 def __init__(self, rank,
              filters,
              kernel_size,
              strides=1,
              padding='valid',
              data_format='channels_last',
              dilation_rate=1,
              activation=None,
              use_bias=True,
              kernel_initializer=None,
              bias_initializer=init_ops.zeros_initializer,
              kernel_regularizer=None,
              bias_regularizer=None,
              activity_regularizer=None,
              trainable=True,
              name=None,
              **kwargs):
   super(_Conv, self).__init__(trainable=trainable,
                               name=name, **kwargs)
   self.rank = rank
   self.filters = filters
   self.kernel_size = utils.normalize_tuple(kernel_size, rank, 'kernel_size')
   self.strides = utils.normalize_tuple(strides, rank, 'strides')
   self.padding = utils.normalize_padding(padding)
   self.data_format = utils.normalize_data_format(data_format)
   self.dilation_rate = utils.normalize_tuple(
       dilation_rate, rank, 'dilation_rate')
   self.activation = activation
   self.use_bias = use_bias
   self.kernel_initializer = kernel_initializer
   self.bias_initializer = bias_initializer
   self.kernel_regularizer = kernel_regularizer
   self.bias_regularizer = bias_regularizer
   self.activity_regularizer = activity_regularizer
Exemple #2
0
 def __init__(self, rank,
              filters,
              kernel_size,
              strides=1,
              padding='valid',
              data_format='channels_last',
              dilation_rate=1,
              activation=None,
              use_bias=True,
              kernel_initializer=None,
              bias_initializer=init_ops.zeros_initializer,
              kernel_regularizer=None,
              bias_regularizer=None,
              activity_regularizer=None,
              trainable=True,
              name=None,
              **kwargs):
   super(_Conv, self).__init__(trainable=trainable,
                               name=name, **kwargs)
   self.rank = rank
   self.filters = filters
   self.kernel_size = utils.normalize_tuple(kernel_size, rank, 'kernel_size')
   self.strides = utils.normalize_tuple(strides, rank, 'strides')
   self.padding = utils.normalize_padding(padding)
   self.data_format = utils.normalize_data_format(data_format)
   self.dilation_rate = utils.normalize_tuple(
       dilation_rate, rank, 'dilation_rate')
   self.activation = activation
   self.use_bias = use_bias
   self.kernel_initializer = kernel_initializer
   self.bias_initializer = bias_initializer
   self.kernel_regularizer = kernel_regularizer
   self.bias_regularizer = bias_regularizer
   self.activity_regularizer = activity_regularizer
Exemple #3
0
 def __init__(self, pool_function, pool_size, strides,
              padding='valid', data_format='channels_last',
              name=None, **kwargs):
   super(_Pooling1D, self).__init__(name=name, **kwargs)
   self.pool_function = pool_function
   self.pool_size = utils.normalize_tuple(pool_size, 1, 'pool_size')
   self.strides = utils.normalize_tuple(strides, 1, 'strides')
   self.padding = utils.normalize_padding(padding)
   self.data_format = utils.normalize_data_format(data_format)
Exemple #4
0
  def testNormalizeTuple(self):
    self.assertEqual(
        conv_utils.normalize_tuple(2, n=3, name='strides'), (2, 2, 2))
    self.assertEqual(
        conv_utils.normalize_tuple((2, 1, 2), n=3, name='strides'), (2, 1, 2))

    with self.assertRaises(ValueError):
      conv_utils.normalize_tuple((2, 1), n=3, name='strides')

    with self.assertRaises(ValueError):
      conv_utils.normalize_tuple(None, n=3, name='strides')