def XOR(x): a1 = NAND(x) a2 = OR(x) a3 = AND(np.array([a1, a2])) y = identity(a3) #출력함수 적용 지점 : q return y
def forward_propagation(network, x): w1, w2, w3 = network['w1'], network['w2'], network['w3'] b1, b2, b3 = network['b1'], network['b2'], network['b3'] a1 = np.dot(x, w1) + b1 z1 = sigmoid(a1) a2 = np.dot(z1, w2) + b2 z2 = sigmoid(a2) a3 = np.dot(z2, w3) + b3 y = identity(a3) return y
# 출력함수(출력층 활성함수) σ() - 항등함수(Identity Function) import os import sys import numpy as np from matplotlib import pyplot as plt from pathlib import Path try: sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib')) from common import identity except ImportError: print('Library Module Can Not Found') x = np.arange(-10, 10, 0.1) y = identity(x) plt.plot(x, y) plt.show()
# 3층 신경망 신호 전달 구현6: 출력층 출력함수 σ() 적용 import os import sys from pathlib import Path try: sys.path.append(os.path.join(os.getcwd())) sys.path.append(os.path.join(Path(os.getcwd()).parent, 'lib')) from ex05 import a3 from common import identity except ImportError: print('Library Module Can Not Found') print('\n= 신호 전달 구현6: 출력층 출력함수 σ() 적용 ======================') print(f'a3 dimension: {a3.shape}') # 2 vector y = identity(a3) print(f'y = {y}')