評價此頁

torch.Tensor.module_load#

Tensor.module_load(other, assign=False)[原始碼]#

定義了在 load_state_dict() 中載入 otherself 時如何轉換 other

get_swap_module_params_on_conversion()True 時使用。

預期 selfnn.Module 中的一個引數或緩衝區,而 other 是具有相應鍵的狀態字典中的值。此方法定義了在 load_state_dict() 中透過 swap_tensors()self 交換之前,other 是如何重新對映的。

注意

此方法應始終返回一個新物件,該物件不是 selfother。例如,預設實現會在 assignFalse 時返回 self.copy_(other).detach(),或者在 assignTrue 時返回 other.detach()

引數