Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Jul 26, 2023

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 theonesud July 26, 2023 13:34
Comment on lines -80 to +81
'Number: {} -- Actual: {} -- Prediction: {}'.format(
num, check_fizbuz(num), outli[hyp[i].max(0)[1].item()]))
f'Number: {num} -- Actual: {check_fizbuz(num)} -- Prediction: {outli[hyp[i].max(0)[1].item()]}'
)
Copy link
Author

Choose a reason for hiding this comment

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

Lines 80-81 refactored with the following changes:

b2 = torch.zeros(1, output_size, requires_grad=True, device=device, dtype=dtype)

no_of_batches = int(len(trX) / batches)
no_of_batches = len(trX) // batches
Copy link
Author

Choose a reason for hiding this comment

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

Lines 35-110 refactored with the following changes:

Comment on lines -92 to +93
x_ = x[0:10]
y_ = y[0:10]
x_ = x[:10]
y_ = y[:10]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 92-93 refactored with the following changes:

Comment on lines -94 to +95
x_ = x[0:10]
y_ = y[0:10]
x_ = x[:10]
y_ = y[:10]
Copy link
Author

Choose a reason for hiding this comment

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

Lines 94-95 refactored with the following changes:

Comment on lines -25 to +30
raise FileNotFoundError("Couldn't find 'labels' folder in {}".format(path))
raise FileNotFoundError(f"Couldn't find 'labels' folder in {path}")
self.files = []
for file in input_files:
name, ext = os.path.splitext(file)
input_file = os.path.join(inputdir_path, file)
label_file = os.path.join(labledir_path, '{}_L{}'.format(name, ext))
label_file = os.path.join(labledir_path, f'{name}_L{ext}')
Copy link
Author

Choose a reason for hiding this comment

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

Function CamvidDataSet.__init__ refactored with the following changes:


model.train()
for epoch in range(epochs):
for _ in range(epochs):
Copy link
Author

Choose a reason for hiding this comment

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

Lines 76-101 refactored with the following changes:

super().__init__()
self.res_blocks = torch.nn.ModuleList()
for s in range(stack_size):
for _ in range(stack_size):
Copy link
Author

Choose a reason for hiding this comment

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

Function ResidualStack.__init__ refactored with the following changes:

decoded = np.argmax(data, axis=axis)

return decoded
return np.argmax(data, axis=axis)
Copy link
Author

Choose a reason for hiding this comment

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

Function one_hot_decode refactored with the following changes:

Comment on lines -58 to +56
waveform = np.sign(expanded) * (np.exp(np.abs(expanded) * np.log(mu + 1)) - 1) / mu

return waveform
return np.sign(expanded) * (np.exp(np.abs(expanded) * np.log(mu + 1)) - 1) / mu
Copy link
Author

Choose a reason for hiding this comment

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

Function mu_law_decode refactored with the following changes:

Comment on lines -72 to +68
self.filenames = [x for x in sorted(os.listdir(data_dir))]
self.filenames = list(sorted(os.listdir(data_dir)))
Copy link
Author

Choose a reason for hiding this comment

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

Function Dataset.__init__ refactored with the following changes:

Comment on lines -119 to +115
return self.sample_size if len(audio[0]) >= self.sample_size\
else len(audio[0])
return min(len(audio[0]), self.sample_size)
Copy link
Author

Choose a reason for hiding this comment

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

Function DataLoader.calc_sample_size refactored with the following changes:

Comment on lines -29 to +30
self.files_A = sorted(glob.glob(os.path.join(root, '%sA' % mode) + '/*.*'))
self.files_B = sorted(glob.glob(os.path.join(root, '%sB' % mode) + '/*.*'))
self.files_A = sorted(glob.glob(f"{os.path.join(root, f'{mode}A')}/*.*"))
self.files_B = sorted(glob.glob(f"{os.path.join(root, f'{mode}B')}/*.*"))
Copy link
Author

Choose a reason for hiding this comment

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

Function ImageDataset.__init__ refactored with the following changes:

Comment on lines +226 to +231
elif random.uniform(0, 1) > 0.5:
i = random.randint(0, self.max_size - 1)
to_return.append(self.data[i].clone())
self.data[i] = element
else:
if random.uniform(0, 1) > 0.5:
i = random.randint(0, self.max_size - 1)
to_return.append(self.data[i].clone())
self.data[i] = element
else:
to_return.append(element)
to_return.append(element)
Copy link
Author

Choose a reason for hiding this comment

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

Function ReplayBuffer.push_and_pop refactored with the following changes:

for epoch in range(opt.epoch, opt.n_epochs):
for i, batch in enumerate(dataloader):
for _ in range(opt.epoch, opt.n_epochs):
for batch in dataloader:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 319-320 refactored with the following changes:

parser.add_argument('--size', type=int, default=256, help='crop to this size')
args = parser.parse_args(args=[])
return args
return parser.parse_args(args=[])
Copy link
Author

Choose a reason for hiding this comment

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

Function get_args refactored with the following changes:

Comment on lines -53 to -54
data_names = []
data_shapes = []
Copy link
Author

Choose a reason for hiding this comment

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

Function MXNetModelService.initialize refactored with the following changes:

Comment on lines -85 to +81
data = batch[0].get('body').get(param_name)
if data:
if data := batch[0].get('body').get(param_name):
self.input = data + 1
tensor = mx.nd.array([self.binary_encoder(self.input, input_size=10)])
return tensor
return mx.nd.array([self.binary_encoder(self.input, input_size=10)])
Copy link
Author

Choose a reason for hiding this comment

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

Function MXNetModelService.preprocess refactored with the following changes:

Comment on lines -117 to +109
out = [{'next_number': prediction}]
return out
return [{'next_number': prediction}]
Copy link
Author

Choose a reason for hiding this comment

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

Function MXNetModelService.postprocess refactored with the following changes:

return input_num
else:
return input_output_map[prediction]
return input_num if prediction == 3 else input_output_map[prediction]
Copy link
Author

Choose a reason for hiding this comment

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

Function get_readable_output refactored with the following changes:

output_dist = output.squeeze().div(0.8).exp()
prob = torch.multinomial(output_dist, 2)
return prob
return torch.multinomial(output_dist, 2)
Copy link
Author

Choose a reason for hiding this comment

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

Function post_processing refactored with the following changes:

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.

1 participant