[WIP] Managing initilizations via a role scheme dictionary#1030
[WIP] Managing initilizations via a role scheme dictionary#1030memimo wants to merge 7 commits intomila-iqia:masterfrom
Conversation
blocks/bricks/interfaces.py
Outdated
| if key in self.initialization_schemes: | ||
| raise ValueError("All initializations are accepted either" | ||
| "through initialization_schemes or " | ||
| "correspodong attribute but not both") |
There was a problem hiding this comment.
also s/attribute/keyword argument/
|
Technically this is @rizar's review but hopefully my comments from the peanut gallery are a little helpful to at least one of you 😛 |
|
@rizar could you please take a look at the high level structure of the PR. I'll take care of the comments of dwf when the high-level is approved. |
|
Sure! Will work on it today. |
|
Sorry for the delay, I am struggling with the cluster and my course project. I will definitely review it tomorrow. |
|
I have three suggestions:
|
|
I reorganized the PR a little bit. Again et's discuss the generality of the PR first, I will fix formatting stuff later. Some notes: 1-The problem with having the roles as keys is that, roles are objects, and different objects of same class will be hashed to different values. So instead I use the name of the roles as the keys. |
22b5a09 to
faf0d27
Compare
|
|
Indeed, def __hash__(self):
return hash(str(self))should work in the case of roles. |
| if self.initialization_schemes is None: | ||
| self.initialization_schemes = {} | ||
|
|
||
| initialization_to_role = {"weights_init": WEIGHT, 'biases_init': BIAS, |
There was a problem hiding this comment.
For the record, it looks like you have chosen to only handle a handful of <role>_init keyword arguments, not all of them. This is probably good, because this clearly makes initialization_schemes the primary way of defining the initialization schemes.
But the code clearly lacks a check if key not in initialization_to_role. Since now we have a clearly defined white list, I would probably raise a warning, that calling the arguments smth_init is recommended, but still pass this argument to the super().__init__ call.
|
I think the major design decision that I disagree with is having both Here is a different design which seems better to me
What do you think? |
| self.parameter_roles.update(set([role])) | ||
|
|
||
| def _initialize(self): | ||
| for param in self.parameters: |
There was a problem hiding this comment.
This is a dangerous code. First, if a parameter has more than one role, it is not clear at all how it should be initialized. I would rather raise an exception upon encountering such a situation. Also, we should choose the most specific initialization scheme (e.g. the one for RECURRENT_WEIGHT and not for just WEIGHT if the parameter is RECURRENT_WEIGHT).
|
@memimo , we should resume working on this, and I really hope we can finish it until I leave Montreal on June 8. |
893a301 to
45d4456
Compare
fixes #970
Re-attempt of #1021
So far it only changes simple.py will propagate changes to other bricks when the format is approved.