cc53003029d11839c394a9544a1394b62721869d,thinc/extra/wrappers.py,PyTorchWrapper,use_params,#PyTorchWrapper#Any#,207
Before Change
@contextlib.contextmanager
def use_params(self, params): // pragma: no cover
if self.id in params:
backup = self.to_bytes()
self.from_bytes(params[self.id])
else:
backup = None
yield
if backup is not None:
self.from_bytes(backup)
After Change
if hasattr(k, "startswith") and k.startswith(key_prefix):
state_dict[k.replace(key_prefix, "")] = xp2torch(v)
if state_dict:
backup = {k: v.clone() for k, v in self._model.state_dict().items()}
self._model.load_state_dict(state_dict)
yield
self._model.load_state_dict(backup)
else:
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances Project Name: explosion/thinc
Commit Name: cc53003029d11839c394a9544a1394b62721869d
Time: 2019-10-18
Author: honnibal+gh@gmail.com
File Name: thinc/extra/wrappers.py
Class Name: PyTorchWrapper
Method Name: use_params
Project Name: KaiyangZhou/deep-person-reid
Commit Name: 205df55987d9c62c13738bebc5ffe18b738f1c50
Time: 2018-11-08
Author: k.zhou@qmul.ac.uk
File Name: train_imgreid_xent.py
Class Name:
Method Name: main
Project Name: horovod/horovod
Commit Name: 6889773ea1f550042e37a219c63ee4f4200e983c
Time: 2021-01-25
Author: tgaddair@gmail.com
File Name: test/parallel/test_torch.py
Class Name: TorchTests
Method Name: test_broadcast_state