Conversation
| if keys == []: | ||
| if not keys: | ||
| for key, value in row.items(): | ||
| keys.append(key) | ||
| values.append(float(value)) | ||
| continue | ||
|
|
||
| for _, value in row.items(): | ||
| values.append(float(value)) | ||
|
|
||
| values.extend(float(value) for _, value in row.items()) |
There was a problem hiding this comment.
Function plot_log refactored with the following changes:
- Replaces an empty collection equality with a boolean operation (
simplify-empty-collection-comparison) - Replace a for append loop with list extend (
for-append-to-extend) - Simplify logical expression using De Morgan identities (
de-morgan)
| return None, input_shape[0][1] * input_shape[0][2] | ||
| else: | ||
| return tuple([None, input_shape[1] * input_shape[2]]) | ||
| return None, input_shape[1] * input_shape[2] |
There was a problem hiding this comment.
Function Mask.compute_output_shape refactored with the following changes:
- Unwrap a constant iterable constructor [×2] (
unwrap-iterable-construction)
| return tuple([None, self.num_capsule, self.dim_vector]) | ||
| return None, self.num_capsule, self.dim_vector |
There was a problem hiding this comment.
Function CapsuleLayer.compute_output_shape refactored with the following changes:
- Unwrap a constant iterable constructor (
unwrap-iterable-construction)
| log = callbacks.CSVLogger(save_dir + '/log2.csv') | ||
| tb = callbacks.TensorBoard(log_dir=save_dir + '/tensorboard-logs', histogram_freq=debug) | ||
| checkpoint = callbacks.ModelCheckpoint(save_dir + '/weights_best.h5', monitor='val_capsnet_acc', | ||
| save_best_only=True, save_weights_only=True, verbose=1) | ||
| log = callbacks.CSVLogger(f'{save_dir}/log2.csv') | ||
| tb = callbacks.TensorBoard( | ||
| log_dir=f'{save_dir}/tensorboard-logs', histogram_freq=debug | ||
| ) | ||
| checkpoint = callbacks.ModelCheckpoint( | ||
| f'{save_dir}/weights_best.h5', | ||
| monitor='val_capsnet_acc', | ||
| save_best_only=True, | ||
| save_weights_only=True, | ||
| verbose=1, | ||
| ) |
There was a problem hiding this comment.
Function train refactored with the following changes:
- Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation)
| shift_fraction = 0.1 | ||
| debug = 0 # debug>0 will save weights by TensorBoard | ||
| save_dir = 'result' | ||
| is_training = 1 |
There was a problem hiding this comment.
Lines 574-611 refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block) - Use named expression to simplify assignment and conditional (
use-named-expression)
This removes the following comments ( why? ):
# as long as weights are given, will run testing
# valid(model=eval_model, data=(x_valid))
Sourcery Code Quality Report✅ Merging this PR will increase code quality in the affected files by 0.41%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
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!