Add info on loading datasets to the tutorial

This commit is contained in:
allevitan
2026-06-16 16:03:40 +02:00
parent ed268a2c9c
commit dd31c39dc4
2 changed files with 68 additions and 4 deletions
+29
View File
@@ -152,3 +152,32 @@ class SimplePtycho(CDIModel):
}
return {**base_results, **results}
@classmethod
def from_results_dict(cls, results_dict):
"""Reconstructs a SimplePtycho model from a results dictionary.
Parameters
----------
results_dict : dict
The dictionary returned by save_results(), as loaded from an h5 file
or produced directly in memory.
Returns
-------
model : SimplePtycho
A fully reconstructed model with all parameters, buffers, and
training metadata restored.
"""
sd = results_dict['state_dict']
model = cls(
wavelength=sd['wavelength'],
probe_basis=sd['probe_basis'],
probe_guess=sd['probe'], # normalized; probe_norm restored by _load_results_dict
obj_guess=sd['obj'],
min_translation=sd['min_translation'],
)
model._load_results_dict(results_dict)
return model