google-deepmind / dm-haiku

JAX-based neural network library
https://dm-haiku.readthedocs.io
Apache License 2.0
2.91k stars 231 forks source link

Add MutableParams and MutableState return types for init_fns. #651

Closed copybara-service[bot] closed 1 year ago

copybara-service[bot] commented 1 year ago

Add MutableParams and MutableState return types for init_fns.

Haiku init_fns always return regular python dicts, so let's be explicit about that! This means downstream use of these mappings can use eg. setitem without the type checker complaining. We accept any Mapping for Params and State inputs, but turn them into a Dict[str, Dict[...]] internally.