more lint

This commit is contained in:
npapernot 2019-07-29 22:15:52 +00:00
parent ed93cf6f44
commit b1f1c47cae
5 changed files with 35 additions and 25 deletions

View file

@ -40,6 +40,7 @@ class StrongConvexMixin:
def radius(self): def radius(self):
"""Radius, R, of the hypothesis space W. """Radius, R, of the hypothesis space W.
W is a convex set that forms the hypothesis space. W is a convex set that forms the hypothesis space.
Returns: Returns:
@ -114,7 +115,7 @@ class StrongConvexHuber(losses.Loss, StrongConvexMixin):
Args: Args:
reg_lambda: Weight regularization constant reg_lambda: Weight regularization constant
C: Penalty parameter C of the loss term c_arg: Penalty parameter C of the loss term
radius_constant: constant defining the length of the radius radius_constant: constant defining the length of the radius
delta: delta value in huber loss. When to switch from quadratic to delta: delta value in huber loss. When to switch from quadratic to
absolute deviation. absolute deviation.
@ -147,7 +148,7 @@ class StrongConvexHuber(losses.Loss, StrongConvexMixin):
) )
def call(self, y_true, y_pred): def call(self, y_true, y_pred):
"""Computes loss """Computes loss.
Args: Args:
y_true: Ground truth values. One hot encoded using -1 and 1. y_true: Ground truth values. One hot encoded using -1 and 1.

View file

@ -200,6 +200,7 @@ class BoltonModel(Model): # pylint: disable=abstract-method
Bolton paper for more description. Bolton paper for more description.
n_samples: number of individual samples in x n_samples: number of individual samples in x
steps_per_epoch: steps_per_epoch:
**kwargs: **kwargs
""" """
if class_weight is None: if class_weight is None:
class_weight = self.calculate_class_weights(class_weight) class_weight = self.calculate_class_weights(class_weight)

View file

@ -275,7 +275,8 @@ def _do_fit(n_samples,
loss: instance of TestLoss loss: instance of TestLoss
distribution: distribution to get noise from. distribution: distribution to get noise from.
Returns: BoltonModel instsance Returns:
BoltonModel instsance
""" """
clf = models.BoltonModel(n_outputs) clf = models.BoltonModel(n_outputs)
clf.compile(optimizer, loss) clf.compile(optimizer, loss)

View file

@ -184,7 +184,7 @@ class Bolton(optimizer_v2.OptimizerV2):
Args: Args:
input_dim: the input dimensionality for the weights input_dim: the input dimensionality for the weights
output_dim the output dimensionality for the weights output_dim: the output dimensionality for the weights
Returns: Returns:
Noise in shape of layer's weights to be added to the weights. Noise in shape of layer's weights to be added to the weights.
@ -236,7 +236,8 @@ class Bolton(optimizer_v2.OptimizerV2):
Args: Args:
name: name:
Returns: attribute from Bolton if specified to come from self, else Returns:
attribute from Bolton if specified to come from self, else
from _internal_optimizer. from _internal_optimizer.
""" """
if name == '_private_attributes' or name in self._private_attributes: if name == '_private_attributes' or name in self._private_attributes:
@ -333,6 +334,9 @@ class Bolton(optimizer_v2.OptimizerV2):
tensor with dim == n_classes. tensor with dim == n_classes.
n_samples: number of rows/individual samples in the training set n_samples: number of rows/individual samples in the training set
batch_size: batch size used. batch_size: batch size used.
Returns:
self
""" """
if epsilon <= 0: if epsilon <= 0:
raise ValueError('Detected epsilon: {0}. ' raise ValueError('Detected epsilon: {0}. '
@ -354,8 +358,8 @@ class Bolton(optimizer_v2.OptimizerV2):
def __exit__(self, *args): def __exit__(self, *args):
"""Exit call from with statement. """Exit call from with statement.
used to
Used to:
1.reset the model and fit parameters passed to the optimizer 1.reset the model and fit parameters passed to the optimizer
to enable the Bolton Privacy guarantees. These are reset to ensure to enable the Bolton Privacy guarantees. These are reset to ensure
that any future calls to fit with the same instance of the optimizer that any future calls to fit with the same instance of the optimizer
@ -363,6 +367,9 @@ class Bolton(optimizer_v2.OptimizerV2):
2.call post-fit methods normalizing/projecting the model weights and 2.call post-fit methods normalizing/projecting the model weights and
adding noise to the weights. adding noise to the weights.
Args:
*args: *args
""" """
self.project_weights_to_r(True) self.project_weights_to_r(True)
for layer in self.layers: for layer in self.layers: