comply to PEP 8
This commit is contained in:
parent
a685db1489
commit
c6ebd02ea9
3 changed files with 11 additions and 10 deletions
|
@ -130,8 +130,9 @@ class Gelu(Activation):
|
||||||
return X * self.cdf
|
return X * self.cdf
|
||||||
|
|
||||||
def backward(self, dY):
|
def backward(self, dY):
|
||||||
return dY * (self.cdf \
|
return dY * (self.cdf
|
||||||
+ np.exp(-_inv2 * np.square(self.X)) * self.X * _invsqrt2pi)
|
+ np.exp(-_inv2 * np.square(self.X))
|
||||||
|
* self.X * _invsqrt2pi)
|
||||||
|
|
||||||
|
|
||||||
class Softmax(Activation):
|
class Softmax(Activation):
|
||||||
|
|
|
@ -31,7 +31,7 @@ class AddSignClip(Optimizer):
|
||||||
self.accum[:] = self.accum * self.mu + dW
|
self.accum[:] = self.accum * self.mu + dW
|
||||||
|
|
||||||
signed = np.sign(dW) * np.sign(self.accum)
|
signed = np.sign(dW) * np.sign(self.accum)
|
||||||
#signed *= decay
|
# signed *= decay
|
||||||
|
|
||||||
inter = dW * (self.alpha + signed)
|
inter = dW * (self.alpha + signed)
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class PowerSignClip(Optimizer):
|
||||||
self.accum[:] = self.accum * self.mu + dW
|
self.accum[:] = self.accum * self.mu + dW
|
||||||
|
|
||||||
signed = np.sign(dW) * np.sign(self.accum)
|
signed = np.sign(dW) * np.sign(self.accum)
|
||||||
#signed *= decay
|
# signed *= decay
|
||||||
|
|
||||||
if self.use_exp:
|
if self.use_exp:
|
||||||
inter = dW * np.exp(signed)
|
inter = dW * np.exp(signed)
|
||||||
|
|
|
@ -75,14 +75,14 @@ class Folding:
|
||||||
class_n = np.max(classes) + 1
|
class_n = np.max(classes) + 1
|
||||||
sorted_inputs = np.array([inputs[classes == n]
|
sorted_inputs = np.array([inputs[classes == n]
|
||||||
for n in range(class_n)], inputs.dtype)
|
for n in range(class_n)], inputs.dtype)
|
||||||
sorted_outputs = np.arange(class_n
|
sorted_outputs = np.arange(class_n) \
|
||||||
).repeat(sorted_inputs.shape[1]).reshape(sorted_inputs.shape[:2])
|
.repeat(sorted_inputs.shape[1]).reshape(sorted_inputs.shape[:2])
|
||||||
|
|
||||||
# now to interleave the classes instead of having them grouped:
|
# now to interleave the classes instead of having them grouped:
|
||||||
inputs = np.swapaxes(sorted_inputs, 0, 1
|
inputs = np.swapaxes(sorted_inputs, 0, 1) \
|
||||||
).reshape(-1, *sorted_inputs.shape[2:])
|
.reshape(-1, *sorted_inputs.shape[2:])
|
||||||
outputs = np.swapaxes(sorted_outputs, 0, 1
|
outputs = np.swapaxes(sorted_outputs, 0, 1) \
|
||||||
).reshape(-1, *sorted_outputs.shape[2:])
|
.reshape(-1, *sorted_outputs.shape[2:])
|
||||||
|
|
||||||
# one final thing: we need to make our outputs one-hot again.
|
# one final thing: we need to make our outputs one-hot again.
|
||||||
self.inputs = inputs
|
self.inputs = inputs
|
||||||
|
|
Loading…
Add table
Reference in a new issue