def all_connection(): W1 = np.random.randn(2, 4) b1 = np.random.randn(4) W2 = np.random.randn(4, 3) b2 = np.random.randn(3) x = np.random.randn(10, 2) # 10個のサンプルデータ h = np.dot(x, W1) + b1 #print(W1) #print(b1) #print(x) print(h) a = Sigmoid.forward(h) s = np.dot(a, W2) + b2 print(s)
# coding: utf-8 import numpy as np import sys sys.path.append('../../') from common.layers import Sigmoid sigmoid = Sigmoid() #--------------------------------------- # forward x = np.array([[1.0, -0.5], [-2.0, 3.0]]) print(x) y = sigmoid.forward(x) print(y) #--------------------------------------- # backward dy = np.array([[5, 5], [5, 5]]) dx = sigmoid.backward(dy) print(dx)