Loads serialized network object from disk. :param file_name: Path to serialized network object on disk. :param map_location: One of ``"cpu"`` or ``"cuda"``. Defaults to ``"cpu"``. :param learning: Whether to load with learning enabled. Default loads value from disk.
(file_name: str, map_location: str = "cpu", learning: bool = None)
| 10 | |
| 11 | |
| 12 | def load(file_name: str, map_location: str = "cpu", learning: bool = None) -> "Network": |
| 13 | # language=rst |
| 14 | """ |
| 15 | Loads serialized network object from disk. |
| 16 | |
| 17 | :param file_name: Path to serialized network object on disk. |
| 18 | :param map_location: One of ``"cpu"`` or ``"cuda"``. Defaults to ``"cpu"``. |
| 19 | :param learning: Whether to load with learning enabled. Default loads value from |
| 20 | disk. |
| 21 | """ |
| 22 | network = torch.load( |
| 23 | open(file_name, "rb"), map_location=map_location, weights_only=False |
| 24 | ) |
| 25 | if learning is not None and "learning" in vars(network): |
| 26 | network.learning = learning |
| 27 | |
| 28 | return network |
| 29 | |
| 30 | |
| 31 | class Network(torch.nn.Module): |
no outgoing calls