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 引數