def add_weight(self,
name,
shape,
dtype=None,
initializer=None,
regularizer=None,
trainable=True,
constraint=None):
"""Adds a weight variable to the layer.
Arguments:
name: String, the name for the weight variable.
shape: The shape tuple of the weight.
dtype: The dtype of the weight.
initializer: An Initializer instance (callable).
regularizer: An optional Regularizer instance.
trainable: A boolean, whether the weight should
be trained via backprop or not (assuming
that the layer itself is also trainable).
constraint: An optional Constraint instance.
Returns:
The created weight variable.
"""
if dtype is None:
dtype = K.floatx()
weight = self.add_variable(
name, shape, dtype=dtype,
initializer=initializer, regularizer=regularizer, trainable=trainable)
if constraint is not None:
self.constraints[weight] = constraint
return weight
评论列表
文章目录