cc53003029d11839c394a9544a1394b62721869d,thinc/extra/wrappers.py,PyTorchWrapper,use_params,#PyTorchWrapper#,207
Before Change
self.from_bytes(params[self.id])
else:
backup = None
yield
if backup is not None:
self.from_bytes(backup)
After Change
def use_params(self, params):
key_prefix = f"pytorch_{self.id}_"
state_dict = {}
for k, v in params.items():
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
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 3
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: pandas-dev/pandas
Commit Name: 7368b2a4e8c6b32b975a62d64efb65bbd6bd1df1
Time: 2020-11-24
Author: 41443370+ivanovmg@users.noreply.github.com
File Name: pandas/io/formats/excel.py
Class Name: ExcelFormatter
Method Name: _format_header_mi
Project Name: pandas-dev/pandas
Commit Name: 7368b2a4e8c6b32b975a62d64efb65bbd6bd1df1
Time: 2020-11-24
Author: 41443370+ivanovmg@users.noreply.github.com
File Name: pandas/io/formats/excel.py
Class Name: ExcelFormatter
Method Name: _format_hierarchical_rows