Skip to content

Sourcery refactored master branch#1

Open
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master
Open

Sourcery refactored master branch#1
sourcery-ai[bot] wants to merge 1 commit into
masterfrom
sourcery/master

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Jul 11, 2022

Copy link
Copy Markdown

Branch master refactored 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 master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai Bot requested a review from rickywesker July 11, 2022 06:41
Comment thread Data Augmented.py
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}')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 24-123 refactored with the following changes:

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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function train_model refactored with the following changes:


with torch.no_grad():
for i, (inputs, labels) in enumerate(dataloaders['val']):
for inputs, labels in dataloaders['val']:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function visualize_model refactored with the following changes:



for i, (inputs, name) in enumerate(dataloaders['val']):
for inputs, name in dataloaders['val']:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 353-414 refactored with the following changes:

Comment thread Transfer Leanring_n.py
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)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function train_model refactored with the following changes:

Comment thread Transfer Leanring_n.py
Comment on lines -162 to +160
for i, (inputs, labels) in enumerate(dataloaders['val']):
for inputs, labels in dataloaders['val']:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function visualize_model refactored with the following changes:

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()

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found the following improvement in Lines 106-120:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants