This class abstracts out parameter creation. One can come up with a new Initializer in order to implement more complex parameter initialization logic
| 8 | |
| 9 | |
| 10 | class Initializer: |
| 11 | ''' |
| 12 | This class abstracts out parameter creation. One can come up with a new |
| 13 | Initializer in order to implement more complex parameter initialization logic |
| 14 | ''' |
| 15 | |
| 16 | def __init__(self, operator_name=None, **kwargs): |
| 17 | self.operator_name = operator_name |
| 18 | self.operator_kwargs = kwargs |
| 19 | |
| 20 | def update(self, operator_name, kwargs): |
| 21 | if self.operator_name is not None: |
| 22 | raise Exception("Operator name overwrites are not allowed") |
| 23 | self.operator_name = operator_name |
| 24 | self.operator_kwargs = kwargs |
| 25 | |
| 26 | def create_param(self, param_name, init_net, shape): |
| 27 | param = init_net.__getattr__(self.operator_name)( |
| 28 | [], param_name, shape=shape, **self.operator_kwargs) |
| 29 | return ParameterInfo( |
| 30 | param_id=None, |
| 31 | param=param, |
| 32 | shape=shape, |
| 33 | ) |
| 34 | |
| 35 | |
| 36 | class ExternalInitializer: |
no outgoing calls
searching dependent graphs…