torch.Tensor

torch.Tensor

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2019 Dec 15 8:27
Editor
Edited
Edited
2025 Oct 29 11:4
Refs
Refs
Tensor
(batch_size, width, height), (batch_size, dim)
  • usually 1D is bias
  • usually 2D is weight matrix
  • usually 3D is sequential or image/video data
# One way tensor = torch.ones([100, 2]).cuda() # Better Code to Create Tensors Directly on GPU tensor = torch.ones([100, 2], device="cuda:0")
Pytorch Tensor member functions
 
 
torch.Tensor members
 
 
Pytorch Tensors
 
 
 

numpy index manipulation

  • […, None] append last dimension
  • [None, …] insert first dimension

Indexing for In-place operations to save memory (
numpy Boolean Indexing
)

x = torch.randn(100, 100, 100) # Large tensor with random values x[x < 0] += 0.1 # Use advanced indexing to update the negative values
 
 
 
02-02 텐서 조작하기(Tensor Manipulation) 1
이번 챕터에서 배울 내용에 대해서 리뷰해보겠습니다. 벡터, 행렬, 텐서의 개념에 대해서 이해하고, Numpy와 파이토치로 벡터, 행렬, 텐서를 다루는 방법에 대해서 이해합니…
02-02 텐서 조작하기(Tensor Manipulation) 1
 
 
 

Recommendations