본문 바로가기
728x90
반응형

Python286

[Tensor] NaN Safe Aggregation Functions NaN (Not a Number) 값을 포함하는 Tensor 인스턴스에서Aggregation Function을 사용할 때,NaN을 무시 또는 특정값으로 처리하는 기능을 제공하는 함수.NumPy기존의 aggregation function의 이름에 nan을 앞에 붙인 이름을 가지며, 수행 중 NaN을 무시함.다음의 함수들이 대표적인 예임.np.nansum, np.nanmean,np.nanmax, np.nanmin, np.nanargmin, np.nanargmax,np.nanmedian,np.nanstd, np.nanvar,np.nanprod,np.nanquantile, np.nanpercentilePyTorch역시, 기존의 aggregation function의 이름에 nan을 앞에 붙인 이름을 가지며, 수.. 2024. 3. 20.
[Tensor] vectorized op. (or universal func) Numpy에서 제공하는 ufunc. (Universal Functions)은 homogeneous and contiguous tensor 에서 모든 elements에 같은 연산을 적용하여기존의 반복 loop에 기반한 연산에 비해 압도적인 속도를 보이면서 간편한 연산자 하나로 처리하도록 지원해줌.ufunc는 일종의 vectorized operation (or vector operation) 임. 실제로 ufunc은 homogeneous and contiguous에 최적화된바이너리 구현물에 대한 binding이라고 볼 수 있음. Python interface가 제공되어 쉽게 사용가능하지만, 내부적으로는 C, C++등의 컴파일 언어로 만들어진 바이너리 구현물이 동작한다고 보면 된다.2024.03.04 - [P.. 2024. 3. 19.
[ML] where: numpy 의 idx찾기 np.where 함수numpy에서 ndarray 인스턴스에서 특정 조건을 만족하는 elements의 위치(index, idx)를 찾는 기능을numpy 모듈의 where 함수가 제공해줌.사실 where 함수는 특정 조건에 따라 값을 바꾸어주는 기능도 있음.다음 글 참조: https://dsaint31.tistory.com/212 NumPy 검색np.where# np.where는 NumPy의 조건 기반 선택 함수np.where(condition[, x, y]) Return elements chosen from x or y depending on condition.condition : 검색에 사용될 조건.실제로 boolean array가 됨.x : condition이 True에 해당하는 위dsaint31.ti.. 2024. 3. 19.
[DL] Tensor: Indexing <Simple, Slicing, Fancy, Boolean Mask> NumPy나 PyTorch, Tensorflow의 텐서들도파이썬의 list 또는 tubple 에서의 indexing과 slicing이 거의 그대로 사용됨.2023.07.12 - [Python] - [Python] list (sequence type) : summary [Python] list (sequence type) : summarylist는 ordered mutable collection으로, collection을 위한 python data type들 중 가장 많이 사용된다. C에서의 array와 같이 가장 기본적인 collection임. 단, heterogeneous item을 가질 수 있으며, 여러 methods를 가지는ds31x.tistory.com 단, multi-dimension에서 squ.. 2024. 3. 18.
[matplotlib] patches: 도형 그리기. patches 는 모듈은Artist 의 subclass인 Patch 클래스들을 제공하여,다음의 다양한 2D 도형을 쉽게 그릴 수 있게 해줌.Arc (호),Circle (원),CirclePolygon (원의 근사 다각형),Ellipse (타원),Arrow (화살표),FancyArrow (모양 변경 기능이 좀 더 보강된 화살표),Rectangle (사각형),RegularPolygon (정규다각형), PathPatch 등등 다음 그림은 Artist와 Patch, 그리고 patches에서 실제 사용되는 다양한 도형을 추상화한 클래스간의 상속관계를 보여줌.간단히 말하면,Patch는 face color와 edge color를 가지는 Artist 임. 예제: 원그리기.간단하게 Circle을 이용하여 원을 그리는 .. 2024. 3. 18.
[DL] Tensor: Transpose and Permute TransposeTranspose(전치)의 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 underlying .. 2024. 3. 16.
728x90
반응형