Create a model from previously saved checkpoint. Parameters ---------- prefix : str path prefix of saved model files. You should have "prefix-symbol.json", "prefix-xxxx.params", and optionally "prefix-xxxx.states", where xxxx is the
(prefix, epoch, load_optimizer_states=False, **kwargs)
| 108 | |
| 109 | @staticmethod |
| 110 | def load(prefix, epoch, load_optimizer_states=False, **kwargs): |
| 111 | """Create a model from previously saved checkpoint. |
| 112 | |
| 113 | Parameters |
| 114 | ---------- |
| 115 | prefix : str |
| 116 | path prefix of saved model files. You should have |
| 117 | "prefix-symbol.json", "prefix-xxxx.params", and |
| 118 | optionally "prefix-xxxx.states", where xxxx is the |
| 119 | epoch number. |
| 120 | epoch : int |
| 121 | epoch to load. |
| 122 | load_optimizer_states : bool |
| 123 | whether to load optimizer states. Checkpoint needs |
| 124 | to have been made with save_optimizer_states=True. |
| 125 | data_names : list of str |
| 126 | Default is `('data')` for a typical model used in image classification. |
| 127 | label_names : list of str |
| 128 | Default is `('softmax_label')` for a typical model used in image |
| 129 | classification. |
| 130 | logger : Logger |
| 131 | Default is `logging`. |
| 132 | context : Context or list of Context |
| 133 | Default is `cpu()`. |
| 134 | work_load_list : list of number |
| 135 | Default `None`, indicating uniform workload. |
| 136 | fixed_param_names: list of str |
| 137 | Default `None`, indicating no network parameters are fixed. |
| 138 | """ |
| 139 | sym, args, auxs = load_checkpoint(prefix, epoch) |
| 140 | mod = Module(symbol=sym, **kwargs) |
| 141 | mod._arg_params = args |
| 142 | mod._aux_params = auxs |
| 143 | mod.params_initialized = True |
| 144 | if load_optimizer_states: |
| 145 | mod._preload_opt_states = '%s-%04d.states'%(prefix, epoch) |
| 146 | return mod |
| 147 | |
| 148 | def save_checkpoint(self, prefix, epoch, save_optimizer_states=False): |
| 149 | """Save current progress to checkpoint. |