Create a model with the given parameters.
(self, params: at.Params, *, remove_extra_params: bool = True)
| 231 | """Create a new model, initializing parameters.""" |
| 232 | |
| 233 | def load(self, params: at.Params, *, remove_extra_params: bool = True) -> "BaseModel": |
| 234 | """Create a model with the given parameters.""" |
| 235 | model = nnx.eval_shape(self.create, jax.random.key(0)) |
| 236 | graphdef, state = nnx.split(model) |
| 237 | if remove_extra_params: |
| 238 | params = ocp.transform_utils.intersect_trees(state.to_pure_dict(), params) |
| 239 | at.check_pytree_equality(expected=state.to_pure_dict(), got=params, check_shapes=True, check_dtypes=False) |
| 240 | state.replace_by_pure_dict(params) |
| 241 | return nnx.merge(graphdef, state) |
| 242 | |
| 243 | def load_pytorch(self, train_config, weight_path: str): |
| 244 | logger.info(f"train_config: {train_config}") |
no outgoing calls