-
Notifications
You must be signed in to change notification settings - Fork 57
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
Support a wider range of dynamically initialized models for MultiNodeOptimizer #148
Conversation
chainermn/optimizers.py
Outdated
return True | ||
return False | ||
else: | ||
return True |
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.
Let us make the case analysis as easy as possible. Here, how about using "early return" as follows (for details, please refer to the book 'The Art of Readable Code'):
if len(previous_params) != len(self.target_params):
return True
for param1, param2 in zip(self.target_params, previous_params):
...
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.
Thanks, I will fix it.
I assume that it is fine, but, for safety, I would like to see some empirical evidence that this change does not affect the performance. I'm concerning the cost for many string comparison. |
Ok, I will check its performance. |
I measured the computing time of
In addition, I also measured the computing time of The computing time of
The computing time of
For the results, the impact of the function is very small. |
Great, thank you for the detailed evaluation! LGTM |
When a new layer is added to a model dynamically, its parameters needs to be sent all nodes.
But, the current MultiNodeOptimizer only sends model parameters first once.
Therefore, I fixed MultinodeOptimizer to send parameters all nodes when a model is changed.