-
Notifications
You must be signed in to change notification settings - Fork 2
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
Sourcery Starbot ⭐ refactored jevenzh/deepplantphenomics #1
base: master
Are you sure you want to change the base?
Conversation
return next(layer for layer in self.__layers if isinstance(layer, layers.convLayer) or isinstance(layer, layers.fullyConnectedLayer)) | ||
return next( | ||
layer | ||
for layer in self.__layers | ||
if isinstance(layer, (layers.convLayer, layers.fullyConnectedLayer)) | ||
) |
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 DPPModel.__first_layer
refactored with the following changes:
- Merge isinstance calls (
merge-isinstance
)
self.weights = tf.get_variable(self.name + '_weights', | ||
shape=self.filter_dimension, | ||
initializer=tf.contrib.layers.xavier_initializer_conv2d()) | ||
self.weights = tf.get_variable( | ||
f'{self.name}_weights', | ||
shape=self.filter_dimension, | ||
initializer=tf.contrib.layers.xavier_initializer_conv2d(), | ||
) | ||
else: | ||
self.weights = tf.get_variable(self.name + '_weights', | ||
shape=self.filter_dimension, | ||
initializer=tf.truncated_normal_initializer(stddev=5e-2), | ||
dtype=tf.float32) | ||
|
||
self.biases = tf.get_variable(self.name + '_bias', | ||
[self.output_size[-1]], | ||
initializer=tf.constant_initializer(0.1), | ||
dtype=tf.float32) | ||
self.weights = tf.get_variable( | ||
f'{self.name}_weights', | ||
shape=self.filter_dimension, | ||
initializer=tf.truncated_normal_initializer(stddev=5e-2), | ||
dtype=tf.float32, | ||
) | ||
|
||
self.biases = tf.get_variable( | ||
f'{self.name}_bias', | ||
[self.output_size[-1]], | ||
initializer=tf.constant_initializer(0.1), | ||
dtype=tf.float32, | ||
) |
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 convLayer.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
self.weights = tf.get_variable(self.name + '_weights', shape=[vec_size, output_size], | ||
initializer=tf.contrib.layers.xavier_initializer()) | ||
self.weights = tf.get_variable( | ||
f'{self.name}_weights', | ||
shape=[vec_size, output_size], | ||
initializer=tf.contrib.layers.xavier_initializer(), | ||
) | ||
else: | ||
self.weights = tf.get_variable(self.name + '_weights', | ||
shape=[vec_size, output_size], | ||
initializer=tf.truncated_normal_initializer(stddev=math.sqrt(2.0/self.output_size)), | ||
dtype=tf.float32) | ||
|
||
self.biases = tf.get_variable(self.name + '_bias', | ||
[self.output_size], | ||
initializer=tf.constant_initializer(0.1), | ||
dtype=tf.float32) | ||
self.weights = tf.get_variable( | ||
f'{self.name}_weights', | ||
shape=[vec_size, output_size], | ||
initializer=tf.truncated_normal_initializer( | ||
stddev=math.sqrt(2.0 / self.output_size) | ||
), | ||
dtype=tf.float32, | ||
) | ||
|
||
self.biases = tf.get_variable( | ||
f'{self.name}_bias', | ||
[self.output_size], | ||
initializer=tf.constant_initializer(0.1), | ||
dtype=tf.float32, | ||
) |
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 fullyConnectedLayer.__init__
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
if deterministic: | ||
return x | ||
else: | ||
return tf.nn.dropout(x, self.p) | ||
return x if deterministic else tf.nn.dropout(x, self.p) |
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 dropoutLayer.forward_pass
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
dense = tf.reshape(values, (batch_size, num_outputs)) | ||
|
||
return dense | ||
return tf.reshape(values, (batch_size, num_outputs)) |
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 label_string_to_tensor
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
unique = set([label.strip() for label in labels]) | ||
unique = {label.strip() for label in labels} |
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 string_labels_to_sequential
refactored with the following changes:
- Replace list(), dict() or set() with comprehension (
collection-builtin-to-comprehension
) - Replace unneeded comprehension with generator (
comprehension-to-generator
)
y = self.model.forward_pass_with_file_inputs(x) | ||
|
||
return y | ||
return self.model.forward_pass_with_file_inputs(x) |
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 arabidopsisStrainClassifier.forward_pass
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
labels = [mapping[index] for index in indices] | ||
|
||
return labels No newline at end of file | ||
return [mapping[index] for index in indices] |
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 tools.classify_arabidopsis_strain
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨
Here's your pull request refactoring your most popular Python repo.
If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.
Review changes via command line
To manually merge these changes, make sure you're on the
master
branch, then run: