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
Data Architect
@ University of Texas at Austin | Austin, TX
Data ETL Engineer
@ University of Texas at Austin | Austin, TX
Lead GNSS Data Scientist
@ Lurra Systems | Melbourne
Senior Machine Learning Engineer (MLOps)
@ Promaton | Remote, Europe
Risk Management - Machine Learning and Model Delivery Services, Product Associate - Senior Associate-
@ JPMorgan Chase & Co. | Wilmington, DE, United States
Senior ML Engineer (Speech/ASR)
@ ObserveAI | Bengaluru