From c6ebd02ea9e92906c65abb4fa800fe2359be0598 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sat, 24 Mar 2018 06:26:02 +0100 Subject: [PATCH] comply to PEP 8 --- onn/activation.py | 5 +++-- onn/experimental.py | 4 ++-- onn/utility.py | 12 ++++++------ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/onn/activation.py b/onn/activation.py index 826666a..a18a1d0 100644 --- a/onn/activation.py +++ b/onn/activation.py @@ -130,8 +130,9 @@ class Gelu(Activation): return X * self.cdf def backward(self, dY): - return dY * (self.cdf \ - + np.exp(-_inv2 * np.square(self.X)) * self.X * _invsqrt2pi) + return dY * (self.cdf + + np.exp(-_inv2 * np.square(self.X)) + * self.X * _invsqrt2pi) class Softmax(Activation): diff --git a/onn/experimental.py b/onn/experimental.py index 1f28e1e..e7c7db7 100644 --- a/onn/experimental.py +++ b/onn/experimental.py @@ -31,7 +31,7 @@ class AddSignClip(Optimizer): self.accum[:] = self.accum * self.mu + dW signed = np.sign(dW) * np.sign(self.accum) - #signed *= decay + # signed *= decay inter = dW * (self.alpha + signed) @@ -64,7 +64,7 @@ class PowerSignClip(Optimizer): self.accum[:] = self.accum * self.mu + dW signed = np.sign(dW) * np.sign(self.accum) - #signed *= decay + # signed *= decay if self.use_exp: inter = dW * np.exp(signed) diff --git a/onn/utility.py b/onn/utility.py index efd65f8..3ef99d2 100644 --- a/onn/utility.py +++ b/onn/utility.py @@ -75,14 +75,14 @@ class Folding: class_n = np.max(classes) + 1 sorted_inputs = np.array([inputs[classes == n] for n in range(class_n)], inputs.dtype) - sorted_outputs = np.arange(class_n - ).repeat(sorted_inputs.shape[1]).reshape(sorted_inputs.shape[:2]) + sorted_outputs = np.arange(class_n) \ + .repeat(sorted_inputs.shape[1]).reshape(sorted_inputs.shape[:2]) # now to interleave the classes instead of having them grouped: - inputs = np.swapaxes(sorted_inputs, 0, 1 - ).reshape(-1, *sorted_inputs.shape[2:]) - outputs = np.swapaxes(sorted_outputs, 0, 1 - ).reshape(-1, *sorted_outputs.shape[2:]) + inputs = np.swapaxes(sorted_inputs, 0, 1) \ + .reshape(-1, *sorted_inputs.shape[2:]) + outputs = np.swapaxes(sorted_outputs, 0, 1) \ + .reshape(-1, *sorted_outputs.shape[2:]) # one final thing: we need to make our outputs one-hot again. self.inputs = inputs