Sourcery refactored master branch#1
Open
sourcery-ai[bot] wants to merge 1 commit into
Open
Conversation
Comment on lines
-24
to
+26
| print('Before scale, shape: {}'.format(im.size)) | ||
| print(f'Before scale, shape: {im.size}') | ||
| new_im = tfs.Resize((100,200))(im) | ||
| print('After scale, shape: {}'.format(new_im.size)) | ||
| print(f'After scale, shape: {new_im.size}') |
Author
There was a problem hiding this comment.
Lines 24-123 refactored with the following changes:
- Replace call to format with f-string [×2] (
use-fstring-for-formatting)
Comment on lines
-207
to
+214
|
|
||
| best_model_wts = copy.deepcopy(model.state_dict()) | ||
| best_acc = 0.0 | ||
|
|
||
| for epoch in range(num_epoch): | ||
| print('Epoch {}/{}'.format(epoch, num_epoch - 1)) | ||
| print(f'Epoch {epoch}/{num_epoch - 1}') | ||
| print('*'*10) | ||
|
|
Author
There was a problem hiding this comment.
Function train_model refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
|
|
||
| with torch.no_grad(): | ||
| for i, (inputs, labels) in enumerate(dataloaders['val']): | ||
| for inputs, labels in dataloaders['val']: |
Author
There was a problem hiding this comment.
Function visualize_model refactored with the following changes:
- Remove unnecessary calls to
enumeratewhen the index is not used (remove-unused-enumerate) - Replace call to format with f-string (
use-fstring-for-formatting)
|
|
||
|
|
||
| for i, (inputs, name) in enumerate(dataloaders['val']): | ||
| for inputs, name in dataloaders['val']: |
Author
There was a problem hiding this comment.
Lines 353-414 refactored with the following changes:
- Remove unnecessary calls to
enumeratewhen the index is not used [×3] (remove-unused-enumerate)
Comment on lines
-86
to
-93
|
|
||
| best_model_wts = copy.deepcopy(model.state_dict()) | ||
| best_acc = 0.0 | ||
|
|
||
| for epoch in range(num_epoch): | ||
| print('Epoch{}/{}'.format(epoch,num_epoch-1)) | ||
| print(f'Epoch{epoch}/{num_epoch - 1}') | ||
| print('-'*10) | ||
|
|
Author
There was a problem hiding this comment.
Function train_model refactored with the following changes:
- Replace call to format with f-string (
use-fstring-for-formatting)
Comment on lines
-162
to
+160
| for i, (inputs, labels) in enumerate(dataloaders['val']): | ||
| for inputs, labels in dataloaders['val']: |
Author
There was a problem hiding this comment.
Function visualize_model refactored with the following changes:
- Remove unnecessary calls to
enumeratewhen the index is not used (remove-unused-enumerate) - Replace call to format with f-string (
use-fstring-for-formatting)
Comment on lines
-106
to
+120
|
|
||
| running_loss = 0 | ||
| for i, data in enumerate(trainloader, 0): | ||
| #get the input | ||
| inputs, labels = data | ||
|
|
||
| #zero the parameter gradients | ||
| optimizer.zero_grad() | ||
|
|
||
| #forward + backward + optimize | ||
| output = net(inputs) | ||
| loss = criterion(output, labels) | ||
| loss.backward() | ||
| optimizer.step() | ||
|
|
Author
There was a problem hiding this comment.
Found the following improvement in Lines 106-120:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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!