(cur_state_dict, pre_state_dict, prefix='', load_name=None)
| 103 | os.makedirs(path) |
| 104 | |
| 105 | def copy_state_dict(cur_state_dict, pre_state_dict, prefix='', load_name=None): |
| 106 | def _get_params(key): |
| 107 | key = prefix + key |
| 108 | if key in pre_state_dict: |
| 109 | return pre_state_dict[key] |
| 110 | return None |
| 111 | for k in cur_state_dict.keys(): |
| 112 | if load_name is not None: |
| 113 | if load_name not in k: |
| 114 | continue |
| 115 | v = _get_params(k) |
| 116 | try: |
| 117 | if v is None: |
| 118 | # print('parameter {} not found'.format(k)) |
| 119 | continue |
| 120 | cur_state_dict[k].copy_(v) |
| 121 | except: |
| 122 | # print('copy param {} failed'.format(k)) |
| 123 | continue |
nothing calls this directly
no test coverage detected