본문 바로가기
728x90
반응형

분류 전체보기352

[DL] Tensor: Transpose and Permute Transpose Transpose(전치)의 linear algebra에서의 정의는 다음과 같음. Given an m x n matrix A, the transpose of A is the n x m matrix, denoted by AT whose columns are formed from the corresponding rows of A. 간단하게 말하면 행과 열을 바꾸는 처리이다. Tensor의 경우 rank가 2 보다 클 수 있으며 해당 rank의 수만큼 축이 있다. 때문에 Tensor에서의 transpose는 여러 축들 중 2개를 서로의 위치를 바꾸는 것이라고 보면 된다. 주의할 것은 numpy와 pytorch의 경우, aixs(축)만 변경된 것이지, 여전히 같은 데이터 (the same und.. 2024. 3. 16.
[DL] Tensor 객체의 attributes: ndim, shape, dtype Python에서 Tensor 를 추상화하는 대표적인 class는 다음과 같음. numpy의 ndarray pytorch의 tensor tensorflow의 constant 이들의 대표적인 attributes는 다음과 같음. dtype: the datatype of element ndim: the number of dimension (차원의 수로, rank라고도 불림) shape: ndim의 객수로 구성된 sequencty type의 인스턴스로 각 축의 크기를 나타냄. 다음은 Tensorflow에서는 지원하지 않으나, torch와 numpy에선 지원하는 것들임. itemsize: element 하나가 차지하는 bytes 크기. size or size(): numpy는 그냥 attribute로, pytorc.. 2024. 3. 15.
[DL] Tensor: dtype 변경(casting) 및 shape 변경. Tensor를 추상화하고 있는 class로는numpy.array: numpy의 ndarraytorch.tensortensorflow.constant: (or tensorflow.Variable)이 있음. 이들은 Python의 sequence types과 달리 일반적으로 다음과 같은 특징을 지님.데이터들이 연속적으로 할당되는 특징의 c,c++의 array와 매우 유사함.element들이 homogeneous인 특징을 가짐 (같은 크기의 unboxed object로 구성=같은 type들)dtyep 변경dtype는 The data type of element 를 가르키며, tensor에서 element의 type을 가르킴.numpy나 tensorflow, torch등이 지원하는 dtype는 다음 URL을 참고.. 2024. 3. 15.
[DL] Tensor 간의 변환: NumPy, PyTorch, TensorFlow pytorch와 numpy의 경우, 텐서를 추상화하고 있는 tensor와 ndarray 를 제공하며, 이 둘은 zero-copy interoperability를 가진다고 말할 수 있을 정도로 상호호환이 가능하다. TensorFlow도 numpy와 상당히 연관되어 있으나, 타입 변환에 있어서 pytorch보다는 불편한 부분이 있다. from 파이썬 시퀀스 타입 (built-in) to 텐서 (numpy, tf, torch) Python의 Sequence Type인 list, tuple 등을 통해 다음의 Tensor 인스턴스를 만들 수 있음. np.array torch.tensor tf.constant (or tf.Variable) t = (1,2,3,4,5,6) a = np.array(t) a_tf = t.. 2024. 3. 15.
[vscode] 기본 terminal 변경. Windows에선ctrl + ` 로 열리는 terminal이 기본으로는 powershelll(PS)인데기본으로 설치된 PS는 버전도 낮고 쓰기가 불편하다. 때문에 command prompt (cmd) 를 쓰도록 변경하는게 보다 편한 경우가 많다. 변경은 ctrl + ,를 통해 "설정"을 열고,상단의 검색에서 shell로 검색을 한 이후,보이는 panel에서 Terminal>Integrated>DefaultProfile:Windows를 찾아서command prompt로 선택한 후 vscode를 재시작하면됨. 같이보면 좋은 자료들2025.01.17 - [utils] - [summary] vscode [summary] vscodevscode 소개 (visual studio 와 비교)https://ds31x.b.. 2024. 3. 12.
[Env] conda 환경설정 스크립트: conda init 환경변수 PATH에 conda를 추가하지 않도록 설치하고 나서, 터미널 등에서 conda를 환경변수 PATH 에 추가하려면, conda prompt 나 conda가 설치된 경로로 이동한 이후, 다음을 수행하면 됨 (Windows의 경우, anaconda prompt 등). conda init 해당 명령어로 변경된 것을 되돌리려면, 다음을 수행. conda init --reverse 같이 읽어보면 좋은 자료들 2023.06.20 - [개발환경] - [Env] Environment Variable (환경변수) [Env] Environment Variable (환경변수) 정의 Environment variable (환경변수) 란, OS나 SW에서 참조하는 변수들로 OS나 SW가 동작 (or 실행)에 영향을 주.. 2024. 3. 11.
728x90
반응형