- 텐서 조작(Tensor Manipulation)에 대해 알아본다.
핵심키워드
- 텐서(Tensor)
- 넘파이(NumPy)
- 텐서 조작(Tensor Manipulation)

1. Tensor는 배열의 집합이다.
2. 차원의 수는 Rank와 같은말이다.
3. 배열의 차원에따라 불리는 이름이 달라진다.
PyTorch Tensor

torch.tensor로 tensor를 만들어낸후 torch.** 의 함수로 각종 계산을 할 수 있다.
TORCH.TENSOR.ADD
Tensor.add(other, *, alpha=1) → Tensor
Add a scalar or tensor to self tensor. If both alpha and other are specified, each element of other is scaled by alpha before being used.
When other is a tensor, the shape of other must be broadcastable with the shape of the underlying tensor
See torch.add()

torch.add — PyTorch 1.9.0 documentation
Shortcuts
pytorch.org
NumPy는 쉽게 Tensor를 표현할 수 있다?
일반적으로 1차원의 넘파이 array를 벡터(vector), 2차원을 행렬(matrix), 3차원부터는 텐서(tensor)라고 합니다. 넘파이 array의 차원이나 데이터 크기(개수)를 보기위해서
>> np.ndim #3부터는 tensor라고 보면 된다
>> np.size
를 사용합니다.
텐서(Tensor)는 다차원 배열입니다. 넘파이(NumPy) ndarray 객체와 비슷하며, tf.Tensor 객체는 데이터 타입과 크기를 가지고 있습니다. 또한 tf.Tensor는 GPU와 같은 가속기 메모리에 상주할 수 있습니다. 텐서플로우는 텐서를 생성하고 이용할 수 있는 풍부한 연산 라이브러리(ex. tf.add, tf.matmul, tf.linalg.inv 등.)를 제공합니다. 이러한 연산은 자동으로 텐서를 파이썬 네이티브(native) 타입으로 변환합니다.
머신러닝 기초 (2) - NumPy 복습
가천대 최성철 교수님의 '밑바닥부터 시작하는 머신러닝 입문'을 수강하며 노트 필기 및 추가 내용 작성을 목적으로 포스팅합니다. 다른 포스팅에서 다루었던 NumPy에 대한 내용이지만 강의를 들
sacko.tistory.com
[튜토리얼1] 텐서플로우 기본(텐서, tf.data.Dataset)
공부중인 개발자 블로그.
limjun92.github.io
[인공지능 개념] Tensor란 무엇인가?
# 인공지능 기초 개념 안녕하세요 코드사기꾼입니다. 오늘은 Tensor에 대한 개념 정립을 하는 시간을 갖도록 하겠습니다. 인공지능 연구분야에서 가장 유명한 라이브러리인 TensorFlow를 정말 많은
rekt77.tistory.com
'AI > PyTorch' 카테고리의 다른 글
[PyTorch] Multivariable Linear Regression (0) | 2021.06.01 |
---|---|
[PyTorch] Linear Regression 작성하기 (0) | 2021.06.01 |
[PyTorch] package (0) | 2021.05.24 |
[pyTorch] 이미지 여는 방법 (0) | 2021.05.12 |
[PyTorch] torch view, squeeze, unsqueeze (0) | 2021.04.27 |