Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
Deep learning with pytorch
pytorch tensors
An short introduction about PyTorch and about the chosen functions.
- torch.device
- torch.linespace
- torch.Tensor.clone
- torch.fmod
- torch.chunk
# Import torch and other required modules
import torch
Function 1 - torch.device
# Example 1
output = torch.device('cpu')
torch.ones([2, 4], dtype=torch.float64, device=output)
tensor([[1., 1., 1., 1.],
[1., 1., 1., 1.]], dtype=torch.float64)
A torch.device is an object representing the device on which a torch. Tensor is or will be allocated. The torch.device contains a device type ( 'cpu' or 'cuda' or any other) and optional device ordinal for the device type.