본문 바로가기
728x90
반응형

Python286

[DL] Tensor 객체의 attributes: ndim, shape, dtype Tensor를 추상화하는 Class들Python에서Tensor 를 추상화하는 대표적인 class는 다음과 같음.NumPy의 ndarray: numpy.arrayPyTorch의 torch.Tensor : torch.tensor()로 생성.Tensorflow의 tf.Tensor : tf.constant(), tf.convert_to_tensor(), tf.Variable 등으로 생성.https://dsaint31.tistory.com/891 [ML] Tensor: Scalar, Vector, Matrix.Tensor 종류1. Scalar (0차원 tensor)하나의 숫자로 표현되는 가장 기본적인 형태.크기(magnitude)만을 가지며 방향은 없음.예시: 온도(25°C), 나이(20), 가격(1000원)# .. 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.arraytorch.tensortf.constant (or tf.Variable)t = (1,2,3,4,5,6)a = np.array(t)a_tf = tf.const.. 2024. 3. 15.
[Python] importlib.util.find_spec() importlib란? importlib 는 개발자가 Python에서 패키지 나 모듈을 로드 및 import 하는 작업들에서 다양한 상호작용을 할 수 있도록 지원하는 API를 제공함. 이를 사용하여, 동적으로 기존의 import된 모듈을 다시 import하여 갱신하는 등의 처리를 할 수 있음. (Python Interpreter를 재시작하거나 Python 프로그램을 재시작하지 않고, 동적으로 import 된 module을 관리. https://dsaint31.tistory.com/527 [Python] importlib.reload : module 재적재 기본적으로 Python의 module은 최초로 import될 때에만 수행이 됨. 때문에 Python session에서 특정 module을 import 하.. 2024. 3. 8.
[matplotlib] matplotlib란 Matplotlib은 Python에서 가장 널리 사용되는 Data Visualization Library임. matplotlib를 통해 chart(차트),image(이미지) 및,다양한 visual representation of data이 가능함.pyplot 모듈을 통해 공학 계산 및 visualization으로 많이 사용되어온 MATLAB와 거의 같은 interface를 제공해줌. matplotlib의 pyplot은 MATLAB과 interface가 유사한 functions의 collection임. https://matplotlib.org/ Matplotlib — Visualization with Pythonseaborn seaborn is a high level interface for drawing.. 2024. 3. 4.
[Programming] glue code and (language) binding Glue Code란glue의 사전적 의미는 "풀" (종이를 붙이는 딱풀 또는 접착제)을 의미한다.glue code란 말 그대로 연결 또는 붙여주는 코드를 가리킴.붙이는 대상을 넣어서 정의하면 다음과 같음."glue code"는서로 다른 소프트웨어 component(or Entity)들을연결하여 작동하게 하는 코드.glue code는서로 다른 데이터 포맷이나 프로그래밍 인터페이스를 가지고 있어서직접적으로 호환되지 않는 시스템(또는 component)들 사이에서 데이터를 변환하거나 메시지를 전달하는 데 사용됨.Glue code: Adapter 및 Wrapper의 활용component들의 다른 interface를 중간에서 변경해주는 adapter나,특정 component를 감싸는 객체를 이용하는 wrapper.. 2024. 3. 4.
728x90
반응형