def get_config(self):
   config = {'filters': self.filters,
             'kernel_size': self.kernel_size,
             'strides': self.strides,
             'padding': self.padding,
             'data_format': self.data_format,
             'dilation_rate': self.dilation_rate,
             'activation': activations.serialize(self.activation),
             'recurrent_activation': activations.serialize(
                 self.recurrent_activation),
             'use_bias': self.use_bias,
             'kernel_initializer': initializers.serialize(
                 self.kernel_initializer),
             'recurrent_initializer': initializers.serialize(
                 self.recurrent_initializer),
             'bias_initializer': initializers.serialize(self.bias_initializer),
             'unit_forget_bias': self.unit_forget_bias,
             'kernel_regularizer': regularizers.serialize(
                 self.kernel_regularizer),
             'recurrent_regularizer': regularizers.serialize(
                 self.recurrent_regularizer),
             'bias_regularizer': regularizers.serialize(self.bias_regularizer),
             'kernel_constraint': constraints.serialize(
                 self.kernel_constraint),
             'recurrent_constraint': constraints.serialize(
                 self.recurrent_constraint),
             'bias_constraint': constraints.serialize(self.bias_constraint),
             'dropout': self.dropout,
             'recurrent_dropout': self.recurrent_dropout}
   base_config = super(ConvLSTM2DCell, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #2
0
 def get_config(self):
   config = {
       'axis': self.axis,
       'momentum': self.momentum,
       'epsilon': self.epsilon,
       'center': self.center,
       'scale': self.scale,
       'beta_initializer': initializers.serialize(self.beta_initializer),
       'gamma_initializer': initializers.serialize(self.gamma_initializer),
       'moving_mean_initializer':
           initializers.serialize(self.moving_mean_initializer),
       'moving_variance_initializer':
           initializers.serialize(self.moving_variance_initializer),
       'beta_regularizer': regularizers.serialize(self.beta_regularizer),
       'gamma_regularizer': regularizers.serialize(self.gamma_regularizer),
       'beta_constraint': constraints.serialize(self.beta_constraint),
       'gamma_constraint': constraints.serialize(self.gamma_constraint)
   }
   # Only add TensorFlow-specific parameters if they are set, so as to preserve
   # model compatibility with external Keras.
   if self.renorm:
     config['renorm'] = True
     config['renorm_clipping'] = self.renorm_clipping
     config['renorm_momentum'] = self.renorm_momentum
   if self.virtual_batch_size is not None:
     config['virtual_batch_size'] = self.virtual_batch_size
   # Note: adjustment is not serializable.
   if self.adjustment is not None:
     logging.warning('The `adjustment` function of this `BatchNormalization` '
                     'layer cannot be serialized and has been omitted from '
                     'the layer config. It will not be included when '
                     're-creating the layer from the saved config.')
   base_config = super(BatchNormalizationBase, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #3
0
 def get_config(self):
   config = {
       'filters':
           self.filters,
       'kernel_size':
           self.kernel_size,
       'strides':
           self.strides,
       'padding':
           self.padding,
       'data_format':
           self.data_format,
       'activation':
           activations.serialize(self.activation),
       'use_bias':
           self.use_bias,
       'kernel_initializer':
           initializers.serialize(self.kernel_initializer),
       'bias_initializer':
           initializers.serialize(self.bias_initializer),
       'kernel_regularizer':
           regularizers.serialize(self.kernel_regularizer),
       'bias_regularizer':
           regularizers.serialize(self.bias_regularizer),
       'activity_regularizer':
           regularizers.serialize(self.activity_regularizer),
       'kernel_constraint':
           constraints.serialize(self.kernel_constraint),
       'bias_constraint':
           constraints.serialize(self.bias_constraint),
       'implementation':
           self.implementation
   }
   base_config = super(LocallyConnected2D, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #4
0
 def get_config(self):
   config = {
       'axis': self.axis,
       'epsilon': self.epsilon,
       'center': self.center,
       'scale': self.scale,
       'beta_initializer': initializers.serialize(self.beta_initializer),
       'gamma_initializer': initializers.serialize(self.gamma_initializer),
       'beta_regularizer': regularizers.serialize(self.beta_regularizer),
       'gamma_regularizer': regularizers.serialize(self.gamma_regularizer),
       'beta_constraint': constraints.serialize(self.beta_constraint),
       'gamma_constraint': constraints.serialize(self.gamma_constraint)
   }
   base_config = super(LayerNormalization, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #5
0
 def get_config(self):
   config = {
       'units': self.units,
       'activation': activations.serialize(self.activation),
       'use_bias': self.use_bias,
       'kernel_initializer': initializers.serialize(self.kernel_initializer),
       'bias_initializer': initializers.serialize(self.bias_initializer),
       'kernel_regularizer': regularizers.serialize(self.kernel_regularizer),
       'bias_regularizer': regularizers.serialize(self.bias_regularizer),
       'activity_regularizer':
           regularizers.serialize(self.activity_regularizer),
       'kernel_constraint': constraints.serialize(self.kernel_constraint),
       'bias_constraint': constraints.serialize(self.bias_constraint)
   }
   base_config = super(Dense, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
 def get_config(self):
   config = {
       'alpha_initializer': initializers.serialize(self.alpha_initializer),
       'alpha_regularizer': regularizers.serialize(self.alpha_regularizer),
       'alpha_constraint': constraints.serialize(self.alpha_constraint),
       'shared_axes': self.shared_axes
   }
   base_config = super(PReLU, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #7
0
 def get_config(self):
   config = {
       'units': self.units,
       'kernel_initializer': initializers.serialize(self.kernel_initializer),
       'recurrent_initializer':
           initializers.serialize(self.recurrent_initializer),
       'bias_initializer': initializers.serialize(self.bias_initializer),
       'kernel_regularizer': regularizers.serialize(self.kernel_regularizer),
       'recurrent_regularizer':
           regularizers.serialize(self.recurrent_regularizer),
       'bias_regularizer': regularizers.serialize(self.bias_regularizer),
       'activity_regularizer':
           regularizers.serialize(self.activity_regularizer),
       'kernel_constraint': constraints.serialize(self.kernel_constraint),
       'recurrent_constraint':
           constraints.serialize(self.recurrent_constraint),
       'bias_constraint': constraints.serialize(self.bias_constraint)
   }
   base_config = super(CuDNNGRU, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #8
0
 def get_config(self):
   kernel_initializer = self.kernel_initializer
   if isinstance(self.kernel_initializer, init_ops.Initializer):
     kernel_initializer = initializers.serialize(self.kernel_initializer)
   config = {
       'output_dim': self.output_dim,
       'kernel_initializer': kernel_initializer,
       'scale': self.scale,
   }
   base_config = super(RandomFourierFeatures, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #9
0
 def get_config(self):
   config = {
       'input_dim': self.input_dim,
       'output_dim': self.output_dim,
       'embeddings_initializer':
           initializers.serialize(self.embeddings_initializer),
       'embeddings_regularizer':
           regularizers.serialize(self.embeddings_regularizer),
       'activity_regularizer':
           regularizers.serialize(self.activity_regularizer),
       'embeddings_constraint':
           constraints.serialize(self.embeddings_constraint),
       'mask_zero': self.mask_zero,
       'input_length': self.input_length
   }
   base_config = super(Embedding, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #10
0
 def get_config(self):
     config = {
         'units': self.units,
         'activation': activations.serialize(self.activation),
         # 'use_bias': self.use_bias,
         'kernel_initializer':
         initializers.serialize(self.kernel_initializer)
         # 'bias_initializer': initializers.serialize(self.bias_initializer),
         # 'kernel_regularizer': regularizers.serialize(self.kernel_regularizer),
         # 'bias_regularizer': regularizers.serialize(self.bias_regularizer),
         # 'activity_regularizer':
         # regularizers.serialize(self.activity_regularizer),
         # 'kernel_constraint': constraints.serialize(self.kernel_constraint),
         # 'bias_constraint': constraints.serialize(self.bias_constraint)
     }
     base_config = super(RWNN, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
Example #11
0
 def get_config(self):
   config = {
       "num_units": self._num_units,
       "use_peepholes": self._use_peepholes,
       "cell_clip": self._cell_clip,
       "initializer": initializers.serialize(self._initializer),
       "num_proj": self._num_proj,
       "proj_clip": self._proj_clip,
       "num_unit_shards": self._num_unit_shards,
       "num_proj_shards": self._num_proj_shards,
       "forget_bias": self._forget_bias,
       "state_is_tuple": self._state_is_tuple,
       "activation": activations.serialize(self._activation),
       "reuse": self._reuse,
   }
   base_config = super(TFLiteLSTMCell, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #12
0
 def get_config(self):
   config = {
       'input_dim': self.input_dim,
       'output_dim': self.output_dim,
       'embeddings_initializer':
           initializers.serialize(self.embeddings_initializer),
       'embeddings_regularizer':
           regularizers.serialize(self.embeddings_regularizer),
       'activity_regularizer':
           regularizers.serialize(self.activity_regularizer),
       'embeddings_constraint':
           constraints.serialize(self.embeddings_constraint),
       'mask_zero': self.mask_zero,
       'input_length': self.input_length
   }
   base_config = super(Embedding, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
Example #13
0
 def get_config(self):
   config = {
       "num_units": self._num_units,
       "use_peepholes": self._use_peepholes,
       "cell_clip": self._cell_clip,
       "initializer": initializers.serialize(self._initializer),
       "num_proj": self._num_proj,
       "proj_clip": self._proj_clip,
       "num_unit_shards": self._num_unit_shards,
       "num_proj_shards": self._num_proj_shards,
       "forget_bias": self._forget_bias,
       "state_is_tuple": self._state_is_tuple,
       "activation": activations.serialize(self._activation),
       "reuse": self._reuse,
   }
   base_config = super(TFLiteLSTMCell, self).get_config()
   return dict(list(base_config.items()) + list(config.items()))
    def get_config(self):
        base_config = super(MultiHeadAttention, self).get_config()

        base_config.update({
            'output_dim':
            self.output_dim,
            'num_heads':
            self.num_heads,
            'negative_infinity':
            self.negative_infinity,
            'padding_value':
            self.padding_value,
            'kernel_initializer':
            initializers.serialize(self.kernel_initializer),
            'kernel_regularizer':
            regularizers.serialize(self.kernel_regularizer),
            'kernel_constraint':
            constraints.serialize(self.kernel_constraint),
        })
        return base_config
Example #15
0
 def get_config(self):
     # TODO this function is copied from Keras.Layers.Dense, and probably needs some further changes for TSRNNDense...?
     config = {
         'units':
         self.units,
         'activation':
         activations.serialize(self.activation),
         'use_bias':
         self.use_bias,
         'kernel_initializer':
         initializers.serialize(self.kernel_initializer),
         'kernel_regularizer':
         regularizers.serialize(self.kernel_regularizer),
         'activity_regularizer':
         regularizers.serialize(self.activity_regularizer),
         'kernel_constraint':
         constraints.serialize(self.kernel_constraint),
     }
     base_config = super(TSDense, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
Example #16
0
 def get_config(self):
     config = {
         'tied_layer':
         '',
         'activation':
         activations.serialize(self.activation),
         'use_bias':
         self.use_bias,
         'bias_initializer':
         initializers.serialize(self.bias_initializer),
         'bias_regularizer':
         regularizers.serialize(self.bias_regularizer),
         'activity_regularizer':
         regularizers.serialize(self.activity_regularizer),
         'bias_constraint':
         constraints.serialize(self.bias_constraint),
         'varName':
         self.varName,
         'varShape':
         self.varShape
     }
     base_config = super(DenseTied, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
Example #17
0
  def test_get_config(self, output_dim, initializer, scale, trainable):
    rff_layer = kernel_layers.RandomFourierFeatures(
        output_dim,
        initializer,
        scale=scale,
        trainable=trainable,
        name='random_fourier_features',
    )
    expected_initializer = initializer
    if isinstance(initializer, init_ops.Initializer):
      expected_initializer = initializers.serialize(initializer)

    expected_config = {
        'output_dim': output_dim,
        'kernel_initializer': expected_initializer,
        'scale': scale,
        'name': 'random_fourier_features',
        'trainable': trainable,
        'dtype': None,
    }
    self.assertLen(expected_config, len(rff_layer.get_config()))
    self.assertSameElements(
        list(expected_config.items()), list(rff_layer.get_config().items()))
Example #18
0
 def get_config(self):
     config = {
         'activation':
         activations.serialize(self.activation),
         'use_bias':
         self.use_bias,
         'kernel_initializer':
         self.kernel_initializer,
         'bias_initializer':
         initializers.serialize(self.bias_initializer),
         'kernel_regularizer':
         self.kernel_regularizer,
         'bias_regularizer':
         regularizers.serialize(self.bias_regularizer),
         'activity_regularizer':
         regularizers.serialize(self.activity_regularizer),
         'kernel_constraint':
         self.kernel_constraint,
         'bias_constraint':
         constraints.serialize(self.bias_constraint)
     }
     base_config = super(_MultiTimeDelayLayer, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
    def test_get_config(self, output_dim, initializer, scale, trainable):
        rff_layer = kernel_layers.RandomFourierFeatures(
            output_dim,
            initializer,
            scale=scale,
            trainable=trainable,
            name='random_fourier_features',
        )
        expected_initializer = initializer
        if isinstance(initializer, init_ops.Initializer):
            expected_initializer = initializers.serialize(initializer)

        expected_config = {
            'output_dim': output_dim,
            'kernel_initializer': expected_initializer,
            'scale': scale,
            'name': 'random_fourier_features',
            'trainable': trainable,
            'dtype': None,
        }
        self.assertLen(expected_config, len(rff_layer.get_config()))
        self.assertSameElements(list(expected_config.items()),
                                list(rff_layer.get_config().items()))
Example #20
0
 def get_config(self):
     config = {
         'axis':
         self.axis,
         'epsilon':
         self.epsilon,
         'momentum':
         self.momentum,
         'center':
         self.center,
         'scale':
         self.scale,
         'beta_initializer':
         initializers.serialize(self.beta_initializer),
         'gamma_initializer':
         initializers.serialize(self.gamma_initializer),
         'mean_weights_initializer':
         initializers.serialize(self.mean_weights_initializer),
         'variance_weights_initializer':
         initializers.serialize(self.variance_weights_initializer),
         'moving_mean_initializer':
         initializers.serialize(self.moving_mean_initializer),
         'moving_variance_initializer':
         initializers.serialize(self.moving_variance_initializer),
         'beta_regularizer':
         regularizers.serialize(self.beta_regularizer),
         'gamma_regularizer':
         regularizers.serialize(self.gamma_regularizer),
         'mean_weights_regularizer':
         regularizers.serialize(self.mean_weights_regularizer),
         'variance_weights_regularizer':
         regularizers.serialize(self.variance_weights_regularizer),
         'beta_constraint':
         constraints.serialize(self.beta_constraint),
         'gamma_constraint':
         constraints.serialize(self.gamma_constraint),
         'mean_weights_constraints':
         constraints.serialize(self.mean_weights_constraints),
         'variance_weights_constraints':
         constraints.serialize(self.variance_weights_constraints),
     }
     base_config = super(SwitchNormalization, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
Example #21
0
 def get_config(self):
     config = {
         'initializer': initializers.serialize(self.initializer),
     }
     base_config = super(Gate, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))
Example #22
0
 def get_config(self):
     config = {
         'units':
             self.units,
         'prior_memory_slots':
             self.prior_memory_slots,
         'posterior_memory_slots':
             self.posterior_memory_slots,
         'num_attention_heads':
             self.num_attention_heads,
         'activation':
             wrap_activations_serialize(self.activation),
         'recurrent_activation':
             wrap_activations_serialize(self.recurrent_activation),
         'mlp_activation':
             wrap_activations_serialize(self.mlp_activation),
         'forget_bias':
             self.forget_bias,
         'input_bias':
             self.input_bias,
         'sigma_bias':
             self.sigma_bias,
         'kernel_initializer':
             initializers.serialize(self.kernel_initializer),
         'recurrent_initializer':
             initializers.serialize(self.recurrent_initializer),
         'attention_initializer':
             initializers.serialize(self.attention_initializer),
         'mlp_initializer':
             initializers.serialize(self.mlp_initializer),
         'bias_initializer':
             initializers.serialize(self.bias_initializer),
         'kernel_regularizer':
             regularizers.serialize(self.kernel_regularizer),
         'recurrent_regularizer':
             regularizers.serialize(self.recurrent_regularizer),
         'attention_regularizer':
             regularizers.serialize(self.attention_regularizer),
         'mlp_regularizer':
             regularizers.serialize(self.mlp_regularizer),
         'activity_regularizer':
             regularizers.serialize(self.activity_regularizer),
         'bias_regularizer':
             regularizers.serialize(self.bias_regularizer),
         'kernel_constraint':
             constraints.serialize(self.kernel_constraint),
         'recurrent_constraint':
             constraints.serialize(self.recurrent_constraint),
         'attention_constraint':
             constraints.serialize(self.attention_constraint),
         'mlp_constraint':
             constraints.serialize(self.mlp_constraint),
         'bias_constraint':
             constraints.serialize(self.bias_constraint),
         'dropout':
             self.dropout,
         'recurrent_dropout':
             self.recurrent_dropout
     }
     base_config = super(TmpHierRNN, self).get_config()
     del base_config['cell']
     return dict(list(base_config.items()) + list(config.items()))
Example #23
0
 def get_config(self):
     config = {
         'sub_units':
         self.sub_units,
         'sub_lstms':
         self.sub_lstms,
         'sub_activation':
         activations.serialize(self.sub_activation),
         'cake_activation':
         activations.serialize(self.cake_activation),
         'sub_use_bias':
         self.sub_use_bias,
         'cake_use_bias':
         self.cake_use_bias,
         'sub_kernel_initializer':
         initializers.serialize(self.sub_kernel_initializer),
         'cake_kernel_initializer':
         initializers.serialize(self.cake_kernel_initializer),
         'sub_recurrent_initializer':
         initializers.serialize(self.sub_recurrent_initializer),
         'cake_recurrent_initializer':
         initializers.serialize(self.cake_recurrent_initializer),
         'sub_bias_initializer':
         initializers.serialize(self.sub_bias_initializer),
         'cake_bias_initializer':
         initializers.serialize(self.cake_bias_initializer),
         'sub_unit_forget_bias':
         self.sub_unit_forget_bias,
         'cake_unit_forget_bias':
         self.cake_unit_forget_bias,
         'sub_kernel_regularizer':
         regularizers.serialize(self.sub_kernel_regularizer),
         'cake_kernel_regularizer':
         regularizers.serialize(self.cake_kernel_regularizer),
         'sub_recurrent_regularizer':
         regularizers.serialize(self.sub_recurrent_regularizer),
         'cake_recurrent_regularizer':
         regularizers.serialize(self.cake_recurrent_regularizer),
         'sub_bias_regularizer':
         regularizers.serialize(self.sub_bias_regularizer),
         'cake_bias_regularizer':
         regularizers.serialize(self.cake_bias_regularizer),
         'activity_regularizer':
         regularizers.serialize(self.activity_regularizer),
         'sub_kernel_constraint':
         constraints.serialize(self.sub_kernel_constraint),
         'cake_kernel_constraint':
         constraints.serialize(self.cake_kernel_constraint),
         'sub_recurrent_constraint':
         constraints.serialize(self.sub_recurrent_constraint),
         'cake_recurrent_constraint':
         constraints.serialize(self.cake_recurrent_constraint),
         'sub_bias_constraint':
         constraints.serialize(self.sub_bias_constraint),
         'cake_bias_constraint':
         constraints.serialize(self.cake_bias_constraint),
         'sub_dropout':
         self.sub_dropout,
         'cake_dropout':
         self.cake_dropout,
         'sub_recurrent_dropout':
         self.sub_recurrent_dropout,
         'cake_recurrent_dropout':
         self.cake_recurrent_dropout,
         'implementation':
         self.implementation
     }
     base_config = super(JujubeCake, self).get_config()
     del base_config['cell']
     return dict(list(base_config.items()) + list(config.items()))
Example #24
0
 def get_config(self):
     config = {
         'units':
         self.units,
         'projection_units':
         self.projection_units,
         'use_feedback':
         self.use_feedback,
         'use_recurrent':
         self.use_recurrent,
         'activation':
         activations.serialize(self.activation),
         'projection_activation':
         activations.serialize(self.projection_activation),
         'use_bias':
         self.use_bias,
         'use_projection_bias':
         self.use_projection_bias,
         'kernel_initializer':
         initializers.serialize(self.kernel_initializer),
         'projection_initializer':
         initializers.serialize(self.projection_initializer),
         'recurrent_initializer':
         initializers.serialize(self.recurrent_initializer),
         'recurrent_initializer':
         initializers.serialize(self.feedback_initializer),
         'bias_initializer':
         initializers.serialize(self.bias_initializer),
         'bias_initializer':
         initializers.serialize(self.projection_bias_initializer),
         'kernel_regularizer':
         regularizers.serialize(self.kernel_regularizer),
         'projection_regularizer':
         regularizers.serialize(self.projection_regularizer),
         'recurrent_regularizer':
         regularizers.serialize(self.recurrent_regularizer),
         'feedback_regularizer':
         regularizers.serialize(self.feedback_regularizer),
         'bias_regularizer':
         regularizers.serialize(self.bias_regularizer),
         'projection_bias_regularizer':
         regularizers.serialize(self.projection_bias_regularizer),
         'kernel_constraint':
         constraints.serialize(self.kernel_constraint),
         'projection_constraint':
         constraints.serialize(self.projection_constraint),
         'recurrent_constraint':
         constraints.serialize(self.recurrent_constraint),
         'feedback_constraint':
         constraints.serialize(self.feedback_constraint),
         'bias_constraint':
         constraints.serialize(self.bias_constraint),
         'projection_bias_constraint':
         constraints.serialize(self.projection_bias_constraint),
         'dropout':
         self.dropout,
         'recurrent_dropout':
         self.recurrent_dropout
     }
     base_config = super(Cell, self).get_config()
     return dict(list(base_config.items()) + list(config.items()))