Map_location用于指定读取数据的映射设备,可以是 a function, torch.device, string or a dict.
map_location可以使用函数来表示,我们来看看 torch doc 中给出的例子:
>>> torch.load('tensors.pt')
# Load all tensors onto the CPU
>>> torch.load('tensors.pt', map_location=torch.device('cpu'))
# Load all tensors onto the CPU, using a function
>>> torch.load('tensors.pt', map_location=lambda storage, loc: storage)
# Load all tensors onto GPU 1
>>> torch.load('tensors.pt', map_location=lambda storage, loc: storage.cuda(1))
当使用函数来指定映射方式时,其格式为:
map_location = lambda storage, loc: dst_storage
其中 storage:



