all AI news
Create and access a tensor in PyTorch
April 13, 2024, 2:41 p.m. | Super Kai (Kazuya Ito)
DEV Community dev.to
tensor() can create the 0D or more D tensor of zero or more integers, floating-point numbers, complex numbers or boolean values as shown below:
*Memos:
tensor() can be used only from torch but not from a tensor.- The default type is float32.
- You can also use one or more tuples to create a 1D or more D tensor.
import torch
torch.tensor(3) # 0D tensor
# tensor(3)
torch.tensor([3, 7, 5]) # 1D tensor
# tensor([3, 7, 5])
torch.tensor([[3, 7, 5], [2, …
access create integers memos numbers pytorch tensor torch tuples type values
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Software Engineer for AI Training Data (School Specific)
@ G2i Inc | Remote
Software Engineer for AI Training Data (Python)
@ G2i Inc | Remote
Software Engineer for AI Training Data (Tier 2)
@ G2i Inc | Remote
Data Engineer
@ Lemon.io | Remote: Europe, LATAM, Canada, UK, Asia, Oceania
Artificial Intelligence – Bioinformatic Expert
@ University of Texas Medical Branch | Galveston, TX
Lead Developer (AI)
@ Cere Network | San Francisco, US