Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

load pt file

>>> 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 tensors from GPU 1 to GPU 0
>>> torch.load('tensors.pt', map_location={'cuda:1':'cuda:0'})
# Load tensor from io.BytesIO object
>>> with open('tensor.pt', 'rb') as f:
...     buffer = io.BytesIO(f.read())
>>> torch.load(buffer)
# Load a module with 'ascii' encoding for unpickling
>>> torch.load('module.pt', encoding='ascii')
Comment

PREVIOUS NEXT
Code Example
Python :: how to raise the exception in __exit__ python 
Python :: concardinate str and a variable in python 
Python :: python module install a whl 
Python :: python sum of list axes 
Python :: python if and 
Python :: sum two columns pandas 
Python :: Python program to combine each line from first file with the corresponding line in second file 
Python :: Range python iterate by 2 
Python :: Python check if all elements exist in another list 
Python :: python terminal game 
Python :: create custom exception python 
Python :: python datetime get date one week from today 
Python :: pandas change period to daily frequency 
Python :: # write json file 
Python :: clone keras model 
Python :: socket exception python 
Python :: tkinter label auto text wrap 
Python :: mse python 
Python :: python scope 
Python :: create dict from two lists 
Python :: longest common subsequence python 
Python :: letters to numbers python 
Python :: python to run excel macro 
Python :: print whole list python 
Python :: go to line in python 
Python :: getenv python 
Python :: automate boring stuff with python 
Python :: python isinstance 
Python :: python cut string to length 
Python :: how to write to a specific line in a file python 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =