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
是狀態字典中具有相應鍵的值,此方法定義在透過load_state_dict()
中的swap_tensors()
與self
交換之前,other
該如何重新映射。注意
此方法應始終返回一個不是
self
或other
的新物件。 例如,如果assign
為False
,則預設實現返回self.copy_(other).detach()
;如果assign
為True
,則返回other.detach()
。- 參數
other (Tensor) – 狀態字典中對應於
self
鍵的值assign (bool) – 傳遞給
nn.Module.load_state_dict()
的 assign 參數