Load model from npz and assign to a network. Parameters ------------- name : str The name of the `.npz` file. network : :class:`Model` The network to be assigned. Examples -------- - See ``tl.files.save_npz``
(name=None, network=None)
| 2021 | |
| 2022 | |
| 2023 | def load_and_assign_npz(name=None, network=None): |
| 2024 | """Load model from npz and assign to a network. |
| 2025 | |
| 2026 | Parameters |
| 2027 | ------------- |
| 2028 | name : str |
| 2029 | The name of the `.npz` file. |
| 2030 | network : :class:`Model` |
| 2031 | The network to be assigned. |
| 2032 | |
| 2033 | Examples |
| 2034 | -------- |
| 2035 | - See ``tl.files.save_npz`` |
| 2036 | |
| 2037 | """ |
| 2038 | if network is None: |
| 2039 | raise ValueError("network is None.") |
| 2040 | |
| 2041 | if not os.path.exists(name): |
| 2042 | logging.error("file {} doesn't exist.".format(name)) |
| 2043 | return False |
| 2044 | else: |
| 2045 | weights = load_npz(name=name) |
| 2046 | assign_weights(weights, network) |
| 2047 | logging.info("[*] Load {} SUCCESS!".format(name)) |
| 2048 | |
| 2049 | |
| 2050 | def save_npz_dict(save_list=None, name='model.npz'): |
nothing calls this directly
no test coverage detected
searching dependent graphs…