728x90 반응형 SMALL 활성화 함수4 신경망을 위한 X 및 Y 생성 분류 신경망을 위한 X 및 Y 생성 이제 x와 y를 생성할 수 있다. 이것이 분류 문제에 대해 y를 생성하는 방법이다. 회귀는 더미를 사용하지 않으며 대상의 숫자 값을 인코딩한다. # Convert to numpy − Classification x_columns = df.columns.drop('product').drop('id') x = df[x_columns].values dummies = pd.get_dummies(df['product']) # Classification products = dummies.columns y = dummies.values x와 y 행렬을 표시할 수 있다. print(x) print(y) [[5.08760000e+04 1.31000000e+01 1.00000000e+00.. 2023. 11. 7. [Deep Learning] 활성화 함수 구현 Sigmoid import numpy as np def sigmoid(x): return 1/(1+np.exp(-x)) sigmoid(4) 0.9820137900379085 import matplotlib.pyplot as plt x = np.arange(-10, 10, 0.01) y = sigmoid(x) plt.plot(x, y) ReLU def relu(x): return np.maximum(0, x) x = np.arange(-10, 10, 0.01) y = relu(x) plt.plot(x, y) Softmax def origin_softmax(x): f_x = np.exp(x) / np.sum(np.exp(x)) return f_x x = np.array([1.3, 5.1, 2.2, 0.7, .. 2022. 11. 17. [PyTorch] 활성화 함수 : Non-linear Activations (weighted sum, nonlinearity) Sigmoid (0 ~ 1) import torchimport matplotlib.pyplot as pltx = torch.linspace(-10, 10, 100)y = torch.sigmoid(x)print(x)print(y)tensor([-10.0000, -9.7980, -9.5960, -9.3939, -9.1919, -8.9899, -8.7879, -8.5859, -8.3838, -8.1818, -7.9798, -7.7778, -7.5758, -7.3737, -7.1717, -6.9697, -6.7677, -6.5657, -6.3636, -6.1616, -5.9596, -5.7576, -5.5556, -5.3535, -.. 2022. 9. 24. [Deep Learning] 활성화 함수 (Activation Function) (1) 활성화 함수 (Activation Function) 입력된 데이터의 weight 합을 출력 신호로 변환하는 함수이다. ANN에서 이전 layer에 대한 weight 합의 크기에 따라 activation 여부가 결정된다. 신경망의 목적에 따라 또는 layer의 역할에 따라 선택적으로 적용한다. Sigmoid 시그모이드 (sigmoid)는 S자 형태라는 의미로, sigmoid 함수는 S자형 곡선의 함수를 의미한다. 정의역은 실수 전체이지만, 유한한 구간(a,b) 사이의 한정된 값을 반환한다. a와 b는 주로 0과 1을 사용한다. sigmoid 함수에서 정의역의 절댓값이 커질수록 미분 값은 0으로 수렴한다. weight가 업데이트되지 않고 소실되는 Gradient vanishing이 발생할 수 있다. Vani.. 2022. 1. 3. 이전 1 다음 728x90 반응형 LIST