-
Notifications
You must be signed in to change notification settings - Fork 21
Sourcery refactored master branch #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| def deconv(c_in, c_out, k_size, stride=2, pad=1, bn=True): | ||
| layers = [] | ||
| layers.append(nn.ConvTranspose2d(c_in, c_out, k_size, stride, pad)) | ||
| layers = [nn.ConvTranspose2d(c_in, c_out, k_size, stride, pad)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function deconv refactored with the following changes:
- Merge append into list declaration (
merge-list-append)
| layers = [] | ||
| layers.append(nn.Conv2d(c_in, c_out, k_size, stride, pad)) | ||
| layers = [nn.Conv2d(c_in, c_out, k_size, stride, pad)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function conv refactored with the following changes:
- Merge append into list declaration (
merge-list-append)
| p = p / np.sum(p) | ||
| c = np.random.choice(vocab_size, 1, p=p)[0] | ||
| return c | ||
| return np.random.choice(vocab_size, 1, p=p)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function pick_top_n refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| samples = [c for c in prime] | ||
| samples = list(prime) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function sample refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension) - Replace unused for index with underscore (
for-index-underscore)
| print('Epoch: {} '.format(e + 1), 'Loss: {:.4f} '.format(batch_loss), | ||
| '{:.4f} sec/batch'.format((end - start))) | ||
| print( | ||
| f'Epoch: {e + 1} ', | ||
| 'Loss: {:.4f} '.format(batch_loss), | ||
| '{:.4f} sec/batch'.format((end - start)), | ||
| ) | ||
|
|
||
| if (counter % save_every_n == 0): | ||
| saver.save(sess, "saves/{}.ckpt".format(counter)) | ||
| saver.save(sess, f"saves/{counter}.ckpt") | ||
|
|
||
| saver.save(sess, "saves/{}.ckpt".format(counter)) | ||
| saver.save(sess, f"saves/{counter}.ckpt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function train refactored with the following changes:
- Replace call to format with f-string [×3] (
use-fstring-for-formatting)
| layers = [] | ||
| layers.append( | ||
| block(self.in_channels, out_channels, stride, downsample)) | ||
| layers = [block(self.in_channels, out_channels, stride, downsample)] | ||
| self.in_channels = out_channels | ||
| for i in range(1, blocks): | ||
| layers.append(block(out_channels, out_channels)) | ||
| layers.extend(block(out_channels, out_channels) for _ in range(1, blocks)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function ResNet.make_layer refactored with the following changes:
- Merge append into list declaration (
merge-list-append) - Replace unused for index with underscore (
for-index-underscore) - Replace a for append loop with list extend (
for-append-to-extend)
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run:Help us improve this pull request!