본문 바로가기

분류 전체보기

(25)
[Numpy] General Broadcasting Rules에 대하여 (작성중) 이번 글에서는 Broadcasting에 대해서 다뤄보도록 하겠습니다. Reference https://numpy.org/doc/stable/user/basics.broadcasting.html Broadcasting — NumPy v1.21 Manual The term broadcasting describes how numpy treats arrays with different shapes during arithmetic operations. Subject to certain constraints, the smaller array is “broadcast” across the larger array so that they have compatible shapes. Broadcasting provi num..
[python] Cosine Similarity를 이용한 color extraction에 대한 검증 이번글 에서는 Cosine Similarity를 이용하여 color extraction에 대한 검증을 간단한 예제를 통해 진행 해 보도록 하겠습니다. Index 0. Introduction 1. vector normaliztion 2. img-unit 3. Target vector 4. img-unit * Target vector 5. cutoff 6. result 0. Introduction color extraction을 위해서 R,G,B 값을 이용하기 편한 이미지를 선택하고 gray scale 준비를 하도록 하겠습니다. import numpy as np import matplotlib.pyplot as plt img = plt.imread('/Users/jaehyeong/Desktop/test/te..
[Numpy] Data type에 대하여 이번 글에서는 넘파이의 Data type에 대해서 알아보도록 하겠습니다. Reference https://numpy.org/doc/stable/user/basics.types.html Data types — NumPy v1.21 Manual Array Scalars NumPy generally returns elements of arrays as array scalars (a scalar with an associated dtype). Array scalars differ from Python scalars, but for the most part they can be used interchangeably (the primary exception is for versions of Python numpy...
[Numpy] ndarray를 알아보자2(reshape, resize,copy,view) 이번 글에서는 ndarray의 reshape , resize, copy, view에 대해 알아보도록 하겠습니다. 1. numpy.reshape(a,newshape,order='c') np.reshape은 원하는 tensor의 형태로 변환해주는 API입니다. 아래는 shape (,6) 을 shape (2,3)으로 변환해주는 예시 코드와 결괏값입니다. import numpy as np a= np.arange(6) b= np.reshape(a,(2,3)) print("original ndarray: \n",a) print("reshaped ndarray: \n",b) original ndarray: [0 1 2 3 4 5] reshaped ndarray: [[0 1 2] [3 4 5]] print("origi..
[Numpy] ndarray에 대해 이번 글에서는 Numpy의 ndarray에 대해서 알아보겠습니다. Reference - numpy공식 문서 https://numpy.org/doc/stable/reference/arrays.ndarray.html The N-dimensional array (ndarray) — NumPy v1.21 Manual Arithmetic and comparison operations on ndarrays are defined as element-wise operations, and generally yield ndarray objects as results. Each of the arithmetic operations (+, -, *, /, //, %, divmod(), ** or pow(), , &, ^, |,..
[python] 파이썬이 동작하는 방식에 대해서2 (가상머신) 이번 글에서는 파이썬이 소스코드를 동작시키는 과정을 살펴보도록 하겠습니다. 이런 다이어그램을 보신적이 있으신가요? 컴파일러가 인터프리터안에 포함되어있는걸 보고 놀라지 않으셨으면 좋겠습니다. 인터프리터는 컴파일러와 가상머신이라는 두 부분으로 나누어져 있기때문입니다. 그렇다면 컴파일러가 하는 일은 무엇일까요? 컴파일러는 우리가 작성한 소스 코드를 바이트 코드로 변환시켜 주는 역할을 합니다. 바이트코드란? lower level 코드이며 플랫폼에 독립적이며 소스코드를 내부적으로 저장하고있죠. 그렇다면 파이썬 가상머신(PVM)란 무엇일까요? 바로 파이썬의 런타임 엔진입니다. 다시말해 PVM은 python 시스템의 일부이기 때문에 별도의 설치가 필요하지 않고 항상 존재합니다. 그럼 본격적으로 소스코드를 동작시키는 ..
[python] 파이썬이 동작하는 방식에 대해서 1 이번 글에서는 파이썬이 동작하는 방식에 대해서 알아보도록 하겠습니다. Reference https://indianpythonista.wordpress.com/2018/01/04/how-python-runs/ How Python runs? First article of 2018 is up! And I decided to go with a very subtle topic this time. Have you ever thought how the Python code is actually executed by the Python interpreter? What steps are carried… indianpythonista.wordpress.com 알아보기에 앞서 가상머신과 커널 그리고 쉘에 대해 간단하게 알아..
[Python] 파이썬은 인터프리터(Interpreter) 언어 인가요? 이번 글에서는 파이썬이 동작하는 과정을 이해하기 위해 '인터프리터'에 대해 다뤄보도록 하겠습니다. 인터프리터 언어란? 기계어로의 명시적인 컴파일 과정 없이 작성한 소스 코드를 인터프리터가 직접 해석하여 바로 프로그램을 실행할 수 있게 해주는 언어 소스코드가 의도하는 작업의 실질적인 수행은 이를 해석한 인터프리터에 의해서 수행됩니다. 따라서 인터프리터는 일종의 가상머신(virtual machine)이나 실행환경(runtime environment) 혹은 에뮬레이터 같은 것으로 이해할 수 있습니다. 실행 시점에 코드를 해석하기 때문에 일반적으로 컴파일러 언어보다는 속도가 떨어지겠죠. 그렇다면 파이썬은 인터프리터 언어일까요? 여기에 대한 대답은 50% Yes 입니다. 파이썬 구현체에는 인터프리터 안에 컴파일러..