torch.Tensor.module_load¶
- Tensor.module_load(other, assign=False)[源][源]¶
定義在透過
load_state_dict()將other載入到self中時如何轉換other。當
get_swap_module_params_on_conversion()為True時使用。預期
self是nn.Module中的引數或緩衝區,而other是 state dictionary 中對應鍵的值,此方法定義了在透過swap_tensors()在load_state_dict()中與self交換之前如何重新對映other。注意
此方法應始終返回一個新物件,該物件不是
self或other。例如,如果assign為False,預設實現返回self.copy_(other).detach();如果assign為True,則返回other.detach()。- 引數
other (Tensor) – state dict 中與
self對應的鍵所對應的值assign (bool) – 傳遞給
nn.Module.load_state_dict()的 assign 引數