本文整理汇总了Python中keras.constraints.get方法的典型用法代码示例。如果您正苦于以下问题:Python constraints.get方法的具体用法?Python constraints.get怎么用?Python constraints.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.constraints
的用法示例。
在下文中一共展示了constraints.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
W_regularizer=None, u_regularizer=None, b_regularizer=None,
W_constraint=None, u_constraint=None, b_constraint=None,
bias=True, **kwargs):
self.init = initializers.get('glorot_uniform')
self.W_regularizer = regularizers.get(W_regularizer)
self.u_regularizer = regularizers.get(u_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.u_constraint = constraints.get(u_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
super(AttentionWithContext, self).__init__(**kwargs)
示例2: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
W_regularizer=None, u_regularizer=None, b_regularizer=None,
W_constraint=None, u_constraint=None, b_constraint=None,
bias=True, **kwargs):
self.supports_masking = True
self.init = initializers.get('glorot_uniform')
self.W_regularizer = regularizers.get(W_regularizer)
self.u_regularizer = regularizers.get(u_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.u_constraint = constraints.get(u_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
super(AttentionWithContext, self).__init__(**kwargs)
示例3: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self, init='glorot_uniform',
U_regularizer=None,
b_start_regularizer=None,
b_end_regularizer=None,
U_constraint=None,
b_start_constraint=None,
b_end_constraint=None,
weights=None,
**kwargs):
super(ChainCRF, self).__init__(**kwargs)
self.init = initializers.get(init)
self.U_regularizer = regularizers.get(U_regularizer)
self.b_start_regularizer = regularizers.get(b_start_regularizer)
self.b_end_regularizer = regularizers.get(b_end_regularizer)
self.U_constraint = constraints.get(U_constraint)
self.b_start_constraint = constraints.get(b_start_constraint)
self.b_end_constraint = constraints.get(b_end_constraint)
self.initial_weights = weights
self.supports_masking = True
self.uses_learning_phase = True
self.input_spec = [InputSpec(ndim=3)]
示例4: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
epsilon=1e-4,
axis=-1,
beta_init='zeros',
gamma_init='ones',
gamma_regularizer=None,
beta_regularizer=None,
**kwargs):
self.supports_masking = True
self.beta_init = initializers.get(beta_init)
self.gamma_init = initializers.get(gamma_init)
self.epsilon = epsilon
self.axis = axis
self.gamma_regularizer = regularizers.get(gamma_regularizer)
self.beta_regularizer = regularizers.get(beta_regularizer)
super(LayerNormalization, self).__init__(**kwargs)
示例5: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
axis=None,
epsilon=1e-3,
center=True,
scale=True,
beta_initializer='zeros',
gamma_initializer='ones',
beta_regularizer=None,
gamma_regularizer=None,
beta_constraint=None,
gamma_constraint=None,
**kwargs):
super(InstanceNormalization, self).__init__(**kwargs)
self.supports_masking = True
self.axis = axis
self.epsilon = epsilon
self.center = center
self.scale = scale
self.beta_initializer = initializers.get(beta_initializer)
self.gamma_initializer = initializers.get(gamma_initializer)
self.beta_regularizer = regularizers.get(beta_regularizer)
self.gamma_regularizer = regularizers.get(gamma_regularizer)
self.beta_constraint = constraints.get(beta_constraint)
self.gamma_constraint = constraints.get(gamma_constraint)
示例6: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
W_regularizer=None, b_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True,
return_attention=False,
**kwargs):
self.supports_masking = True
self.return_attention = return_attention
self.init = initializers.get('glorot_uniform')
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
super(Attention, self).__init__(**kwargs)
示例7: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
W_regularizer=None, u_regularizer=None, b_regularizer=None,
W_constraint=None, u_constraint=None, b_constraint=None,
bias=True,
return_attention=False, **kwargs):
self.supports_masking = True
self.return_attention = return_attention
self.init = initializers.get('glorot_uniform')
self.W_regularizer = regularizers.get(W_regularizer)
self.u_regularizer = regularizers.get(u_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.u_constraint = constraints.get(u_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
super(AttentionWithContext, self).__init__(**kwargs)
示例8: on_epoch_end
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def on_epoch_end(self, epoch, logs=None):
logs = logs or {}
self.epochs_since_last_save += 1
if self.epochs_since_last_save >= self.period:
self.epochs_since_last_save = 0
#filepath = self.filepath.format(epoch=epoch + 1, **logs)
current = logs.get(self.monitor)
if current is None:
warnings.warn('Can pick best model only with %s available, '
'skipping.' % (self.monitor), RuntimeWarning)
else:
if self.monitor_op(current, self.best):
if self.verbose > 0:
print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
' storing weights.'
% (epoch + 1, self.monitor, self.best,
current))
self.best = current
self.best_epochs = epoch + 1
self.best_weights = self.model.get_weights()
else:
if self.verbose > 0:
print('\nEpoch %05d: %s did not improve' %
(epoch + 1, self.monitor))
示例9: evaluate
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def evaluate(self, inputs, fn_inverse=None, fn_plot=None):
try:
X, y = inputs
inputs = X
except:
X, conditions, y = inputs
inputs = [X, conditions]
y_hat = self.predict(inputs)
if fn_inverse is not None:
y_hat = fn_inverse(y_hat)
y = fn_inverse(y)
if fn_plot is not None:
fn_plot([y, y_hat])
results = []
for m in self.model.metrics:
if isinstance(m, str):
results.append(K.eval(K.mean(get(m)(y, y_hat))))
else:
results.append(K.eval(K.mean(m(y, y_hat))))
return results
示例10: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self, init='glorot_uniform',
U_regularizer=None, b_start_regularizer=None, b_end_regularizer=None,
U_constraint=None, b_start_constraint=None, b_end_constraint=None,
weights=None,
**kwargs):
self.supports_masking = True
self.uses_learning_phase = True
self.input_spec = [InputSpec(ndim=3)]
self.init = initializations.get(init)
self.U_regularizer = regularizers.get(U_regularizer)
self.b_start_regularizer = regularizers.get(b_start_regularizer)
self.b_end_regularizer = regularizers.get(b_end_regularizer)
self.U_constraint = constraints.get(U_constraint)
self.b_start_constraint = constraints.get(b_start_constraint)
self.b_end_constraint = constraints.get(b_end_constraint)
self.initial_weights = weights
super(ChainCRF, self).__init__(**kwargs)
示例11: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
W_regularizer=None,
b_regularizer=None,
W_constraint=None,
b_constraint=None,
bias=True, **kwargs):
"""
Keras Layer that implements an Content Attention mechanism.
Supports Masking.
"""
self.supports_masking = True
self.init = initializers.get('glorot_uniform')
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
super(Attention, self).__init__(**kwargs)
示例12: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self, units, kernel_initializer='glorot_uniform',
activation=None, weights=None,
kernel_regularizer=None, bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None, bias_constraint=None,
use_bias=True, **kwargs):
if 'input_shape' not in kwargs and 'input_dim' in kwargs:
kwargs['input_shape'] = (kwargs.pop('input_dim'),)
self.kernel_initializer = initializers.get(kernel_initializer)
self.activation = activations.get(activation)
self.units = units
self.kernel_regularizer = regularizers.get(kernel_regularizer)
self.bias_regularizer = regularizers.get(bias_regularizer)
self.activity_regularizer = regularizers.get(activity_regularizer)
self.kernel_constraint = constraints.get(kernel_constraint)
self.bias_constraint = constraints.get(bias_constraint)
self.use_bias = use_bias
self.initial_weights = weights
super(CosineDense, self).__init__(**kwargs)
示例13: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self, alpha_initializer='ones',
alpha_regularizer=None,
alpha_constraint=None,
beta_initializer='ones',
beta_regularizer=None,
beta_constraint=None,
shared_axes=None,
**kwargs):
super(PELU, self).__init__(**kwargs)
self.supports_masking = True
self.alpha_initializer = initializers.get(alpha_initializer)
self.alpha_regularizer = regularizers.get(alpha_regularizer)
self.alpha_constraint = constraints.get(alpha_constraint)
self.beta_initializer = initializers.get(beta_initializer)
self.beta_regularizer = regularizers.get(beta_regularizer)
self.beta_constraint = constraints.get(beta_constraint)
if shared_axes is None:
self.shared_axes = None
elif not isinstance(shared_axes, (list, tuple)):
self.shared_axes = [shared_axes]
else:
self.shared_axes = list(shared_axes)
示例14: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self,
num_capsule,
dim_capsule,
routings=3,
share_weights=True,
initializer='glorot_uniform',
activation=None,
regularizer=None,
constraint=None,
**kwargs):
super(Capsule, self).__init__(**kwargs)
self.num_capsule = num_capsule
self.dim_capsule = dim_capsule
self.routings = routings
self.share_weights = share_weights
self.activation = activations.get(activation)
self.regularizer = regularizers.get(regularizer)
self.initializer = initializers.get(initializer)
self.constraint = constraints.get(constraint)
示例15: __init__
# 需要导入模块: from keras import constraints [as 别名]
# 或者: from keras.constraints import get [as 别名]
def __init__(self, output_dim, output_length,
init='glorot_uniform', inner_init='orthogonal',
activation='tanh',
W_regularizer=None, U_regularizer=None, b_regularizer=None,
dropout_W=0., dropout_U=0., **kwargs):
self.output_dim = output_dim
self.output_length = output_length
self.init = initializations.get(init)
self.inner_init = initializations.get(inner_init)
self.activation = activations.get(activation)
self.W_regularizer = regularizers.get(W_regularizer)
self.U_regularizer = regularizers.get(U_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.dropout_W, self.dropout_U = dropout_W, dropout_U
if self.dropout_W or self.dropout_U:
self.uses_learning_phase = True
super(DreamyRNN, self).__init__(**kwargs)