티스토리 뷰
Numpy 항목별 적용하는 함수(ufunc)¶
https://docs.scipy.org/doc/numpy-1.15.1/reference/ufuncs.html
설명x, 밑에보면 다양한 함수들이 나와있다.
136p
In [7]:
import numpy as np
np.floor(1.1), np.ceil(1.1), np.floor(1.0), np.ceil(1.0)
Out[7]:
In [1]:
import numpy as np
import matplotlib.pyplot as plt
In [2]:
a = np.arange(9).reshape(3,3)
a
Out[2]:
In [37]:
np.square(a)
Out[37]:
In [38]:
a ** 2
Out[38]:
In [39]:
np.sqrt(a)
Out[39]:
In [40]:
a ** 0.5
Out[40]:
In [41]:
np.exp(a)
Out[41]:
In [42]:
np.log(a)
Out[42]:
In [43]:
np.add(a, 1)
Out[43]:
In [8]:
np.multiply(a,2)
Out[8]:
In [12]:
np.maximum(a,5) # a와 5중에서 큰 값을 적용
Out[12]:
In [13]:
b = np.random.randn(5,5)
b
Out[13]:
In [14]:
np.maximum(b,0)
Out[14]:
In [44]:
np.abs(b)
Out[44]:
In [45]:
np.sign(b)
Out[45]:
In [46]:
c = np.arange(100)
plt.plot(c)
Out[46]:
In [47]:
c = np.arange(10)
d = np.power(c,2)
plt.plot(c)
plt.plot(d)
Out[47]:
In [17]:
c=np.arange(10)
d=np.log(c+1)
plt.plot(c)
plt.plot(d)
Out[17]:
In [22]:
c=np.arange(0.0001,10,0.0001)
d=np.log(c)
plt.plot(c)
plt.plot(d)
Out[22]:
In [48]:
c = np.arange(0.01, 1, 0.01)
d = 1/c
plt.plot(c)
plt.plot(d)
Out[48]:
In [24]:
c = np.arange(-10,10) # 어떤 값보다 클때만 신호를 주고 싶을때
d = np.maximum(c,0)
plt.plot(c)
plt.plot(d)
Out[24]:
In [27]:
rng = np.arange(-5,5,0.1)
sigmoid = 1/(1+np.exp(-rng))
plt.plot(rng, sigmoid)
Out[27]:
In [26]:
rng = np.arange(-5,5,0.1)
sigmoid = 1/(1+np.exp(-rng))
plt.plot(rng, sigmoid)
plt.hlines([0,0.5,1],-5,5, linestyles=':')
plt.vlines([0],0,1, linestyles='--')
Out[26]:
-5~5 사이에 0.1 간격으로 숫자를 뽑아낸다.¶
In [35]:
np.arange(-5,5,0.1) #간격 0.1
Out[35]:
In [36]:
np.linspace(-5,5,101) #개수 101개
Out[36]:
'beginner > 파이썬 기초' 카테고리의 다른 글
NumPy_정렬 (0) | 2019.02.15 |
---|---|
NumPy_파일입출력 (0) | 2019.02.14 |
NumPy_사칙연산 (0) | 2019.02.13 |
NumPy_랜덤-2 (0) | 2019.02.13 |
NumPy_랜덤-1 (0) | 2019.02.12 |