October 2018
Beginner
362 pages
9h 32m
English
Such as TensorFlow, PyTorch represents data in tensor form. Torch tensors are defined as standard data types, such as torch.FloatTensor() , torch.charTensor(), and torch.intTensor(). As mentioned, operations in PyTorch are highly Pythonic. To repeat the exact same multiplication operation that we performed in preceding TensorFlow:
import torch x = torch.IntTensor([4])y = torch.IntTensor([5])product = x * y
As a result of it native Python feel, PyTorch allows for easy interaction between standard numpy arrays and PyTorch tensors. It's easy to switch back and forth between the two:
import torch import numpy as np## Create a numpy arraynumpy_array = np.random.randn(20,20)##Convert the numpy array to a pytorch tensorpytorch_tensor ...
Read now
Unlock full access