Sourcery Starbot ⭐ refactored manncodes/xeno#1
Sourcery Starbot ⭐ refactored manncodes/xeno#1SourceryAI wants to merge 1 commit intomanncodes:masterfrom
Conversation
|
|
||
| def derivative(self, input=None): | ||
| last_forward = input if input else self.last_forward | ||
| last_forward = input or self.last_forward |
There was a problem hiding this comment.
Function ReLU.derivative refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity)
|
|
||
| def derivative(self, input=None): | ||
| last_forward = input if input else self.last_forward | ||
| last_forward = input or self.last_forward |
There was a problem hiding this comment.
Function Linear.derivative refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity)
| exp_x = np.exp(x) | ||
| s = exp_x / np.sum(exp_x, axis=1, keepdims=True) | ||
| return s | ||
| return exp_x / np.sum(exp_x, axis=1, keepdims=True) |
There was a problem hiding this comment.
Function Softmax.forward refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| last_forward = input if input else self.last_forward | ||
| last_forward = input or self.last_forward |
There was a problem hiding this comment.
Function Softmax.derivative refactored with the following changes:
- Simplify if expression by using or (
or-if-exp-identity)
| fan_out = size[1] | ||
|
|
||
| elif len(size) == 4 or len(size) == 5: | ||
| elif len(size) in [4, 5]: |
There was a problem hiding this comment.
Function decompose_size refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| while iter_idx < max_iter: | ||
| iter_idx += 1 | ||
|
|
||
| for iter_idx in range(1, max_iter + 1): |
There was a problem hiding this comment.
Function Model.fit refactored with the following changes:
- Replace while with for (
while-to-for)
| y_pred = x_next | ||
| return y_pred | ||
| return x_next |
There was a problem hiding this comment.
Function Model.predict refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| linear_out = np.dot(input, self.W) + self.b | ||
| act_out = self.act_layer.forward(linear_out) | ||
| return act_out | ||
| return self.act_layer.forward(linear_out) |
There was a problem hiding this comment.
Function Dense.forward refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| if train: | ||
| self.last_mask = get_rng().binomial(1, 1 - self.p, input.shape) / (1 - self.p) | ||
| return input * self.last_mask | ||
| else: | ||
| if not train: | ||
| return input * (1 - self.p) | ||
| self.last_mask = get_rng().binomial(1, 1 - self.p, input.shape) / (1 - self.p) | ||
| return input * self.last_mask |
There was a problem hiding this comment.
Function Dropout.forward refactored with the following changes:
- Swap if/else branches (
swap-if-else-branches) - Remove unnecessary else after guard condition (
remove-unnecessary-else)
| dx = dx1 + dx2 | ||
|
|
||
| return dx | ||
| return dx1 + dx2 |
There was a problem hiding this comment.
Function BatchNormal.backward refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
This removes the following comments ( why? ):
# step0 done!
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: