Python keras.constraints() Examples
The following are 6
code examples of keras.constraints().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
keras
, or try the search function
.
Example #1
Source File: timedistributed.py From fancy-cnn with MIT License | 6 votes |
def build(self): try: self.input_ndim = len(self.previous.input_shape) except AttributeError: self.input_ndim = len(self.input_shape) self.layer.set_input_shape((None, ) + self.input_shape[2:]) if hasattr(self.layer, 'regularizers'): self.regularizers = self.layer.regularizers if hasattr(self.layer, 'constraints'): self.constraints = self.layer.constraints if hasattr(self.layer, 'trainable_weights'): self.trainable_weights = self.layer.trainable_weights if self.initial_weights is not None: self.layer.set_weights(self.initial_weights) del self.initial_weights
Example #2
Source File: bn.py From deep_complex_networks with MIT License | 6 votes |
def get_config(self): config = { 'axis': self.axis, 'momentum': self.momentum, 'epsilon': self.epsilon, 'center': self.center, 'scale': self.scale, 'beta_initializer': sanitizedInitSer(self.beta_initializer), 'gamma_diag_initializer': sanitizedInitSer(self.gamma_diag_initializer), 'gamma_off_initializer': sanitizedInitSer(self.gamma_off_initializer), 'moving_mean_initializer': sanitizedInitSer(self.moving_mean_initializer), 'moving_variance_initializer': sanitizedInitSer(self.moving_variance_initializer), 'moving_covariance_initializer': sanitizedInitSer(self.moving_covariance_initializer), 'beta_regularizer': regularizers.serialize(self.beta_regularizer), 'gamma_diag_regularizer': regularizers.serialize(self.gamma_diag_regularizer), 'gamma_off_regularizer': regularizers.serialize(self.gamma_off_regularizer), 'beta_constraint': constraints .serialize(self.beta_constraint), 'gamma_diag_constraint': constraints .serialize(self.gamma_diag_constraint), 'gamma_off_constraint': constraints .serialize(self.gamma_off_constraint), } base_config = super(ComplexBatchNormalization, self).get_config() return dict(list(base_config.items()) + list(config.items()))
Example #3
Source File: FixedEmbedding.py From deeplearning4nlp-tutorial with Apache License 2.0 | 6 votes |
def __init__(self, input_dim, output_dim, init='uniform', input_length=None, W_regularizer=None, activity_regularizer=None, W_constraint=None, mask_zero=False, weights=None, **kwargs): self.input_dim = input_dim self.output_dim = output_dim self.init = initializations.get(init) self.input_length = input_length self.mask_zero = mask_zero self.W_constraint = constraints.get(W_constraint) self.constraints = [self.W_constraint] self.W_regularizer = regularizers.get(W_regularizer) self.activity_regularizer = regularizers.get(activity_regularizer) self.initial_weights = weights kwargs['input_shape'] = (self.input_dim,) super(FixedEmbedding, self).__init__(**kwargs)
Example #4
Source File: ConvolutionalMaxOverTime.py From deeplearning4nlp-tutorial with Apache License 2.0 | 6 votes |
def __init__(self, output_dim, init='glorot_uniform', activation='linear', weights=None, W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, input_dim=None, **kwargs): self.init = initializations.get(init) self.activation = activations.get(activation) self.output_dim = output_dim self.W_regularizer = regularizers.get(W_regularizer) self.b_regularizer = regularizers.get(b_regularizer) self.activity_regularizer = regularizers.get(activity_regularizer) self.W_constraint = constraints.get(W_constraint) self.b_constraint = constraints.get(b_constraint) self.constraints = [self.W_constraint, self.b_constraint] self.initial_weights = weights self.input_dim = input_dim if self.input_dim: kwargs['input_shape'] = (self.input_dim,) super(ConvolutionalMaxOverTime, self).__init__(**kwargs)
Example #5
Source File: ConvolutionalMaxOverTime.py From deeplearning4nlp-tutorial with Apache License 2.0 | 6 votes |
def __init__(self, output_dim, init='glorot_uniform', activation='linear', weights=None, W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, input_dim=None, **kwargs): self.init = initializations.get(init) self.activation = activations.get(activation) self.output_dim = output_dim self.W_regularizer = regularizers.get(W_regularizer) self.b_regularizer = regularizers.get(b_regularizer) self.activity_regularizer = regularizers.get(activity_regularizer) self.W_constraint = constraints.get(W_constraint) self.b_constraint = constraints.get(b_constraint) self.constraints = [self.W_constraint, self.b_constraint] self.initial_weights = weights self.input_dim = input_dim if self.input_dim: kwargs['input_shape'] = (self.input_dim,) super(ConvolutionalMaxOverTime, self).__init__(**kwargs)
Example #6
Source File: bn.py From deep_complex_networks with MIT License | 5 votes |
def __init__(self, axis=-1, momentum=0.9, epsilon=1e-4, center=True, scale=True, beta_initializer='zeros', gamma_diag_initializer='sqrt_init', gamma_off_initializer='zeros', moving_mean_initializer='zeros', moving_variance_initializer='sqrt_init', moving_covariance_initializer='zeros', beta_regularizer=None, gamma_diag_regularizer=None, gamma_off_regularizer=None, beta_constraint=None, gamma_diag_constraint=None, gamma_off_constraint=None, **kwargs): super(ComplexBatchNormalization, self).__init__(**kwargs) self.supports_masking = True self.axis = axis self.momentum = momentum self.epsilon = epsilon self.center = center self.scale = scale self.beta_initializer = sanitizedInitGet(beta_initializer) self.gamma_diag_initializer = sanitizedInitGet(gamma_diag_initializer) self.gamma_off_initializer = sanitizedInitGet(gamma_off_initializer) self.moving_mean_initializer = sanitizedInitGet(moving_mean_initializer) self.moving_variance_initializer = sanitizedInitGet(moving_variance_initializer) self.moving_covariance_initializer = sanitizedInitGet(moving_covariance_initializer) self.beta_regularizer = regularizers.get(beta_regularizer) self.gamma_diag_regularizer = regularizers.get(gamma_diag_regularizer) self.gamma_off_regularizer = regularizers.get(gamma_off_regularizer) self.beta_constraint = constraints .get(beta_constraint) self.gamma_diag_constraint = constraints .get(gamma_diag_constraint) self.gamma_off_constraint = constraints .get(gamma_off_constraint)