Exemplo n.º 1
0
def predict(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 = sig.sigmoid(a1)
    a2 = np.dot(z1, W2) + b2
    z2 = sig.sigmoid(a2)
    a3 = np.dot(z2, W3) + b3
    y = sm.softmax(a3)
    return y
Exemplo n.º 2
0
def forward(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 = sig.sigmoid(a1)
    a2 = np.dot(z1, W2) + b2
    z2 = sig.sigmoid(a2)
    a3 = np.dot(z2, W3) + b3
    y = identity_function(a3)
    return y
Exemplo n.º 3
0
import numpy as np
import sys
sys.path.append("../")
from functions import sigmoid as sig

# 式3.9
X = np.array([1.0, 0.5])
W1 = np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]])
B1 = np.array([0.1, 0.2, 0.3])

print(W1.shape)
print(X.shape)
print(B1.shape)

A1 = np.dot(X, W1) + B1
Z1 = sig.sigmoid(A1)

print(A1)
print(Z1)

W2 = np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]])
B2 = np.array([0.1, 0.2])

print(Z1.shape)
print(W2.shape)
print(B2.shape)

A2 = np.dot(Z1, W2) + B2
Z2 = sig.sigmoid(A2)

Exemplo n.º 4
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

# 3.2.4 シグモイド関数の実装
import numpy as np
import matplotlib.pylab as plt
import sys
sys.path.append("../")
from functions import sigmoid as sig

# データ出力
x = np.array([-1.0, 1.0, 2.0])
print(sig.sigmoid(x))

# シグモイド関数とNumPy配列の具体例
t = np.array([1.0, 2.0, 3.0])
print(1.0 + t)
print(1.0 / t)

# シグモイド関数の描画
x = np.arange(-5.0, 5.0, 0.1)
y = sig.sigmoid(x)
plt.plot(x, y)
plt.ylim(-0.1, 1.1)
plt.show()
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

# 3.2.5 シグモイド関数とステップ関数の比較
import numpy as np
import matplotlib.pylab as plt
import sys
sys.path.append("../")
from functions import sigmoid as sig
from functions import step_function as stp


# x軸範囲定義
x = np.arange(-5.0, 5.0, 0.1)


# シグモイド関数定義
sigmoid = sig.sigmoid(x)


# ステップ関数定義
step = stp.step_function(x)


# 画面描画
plt.plot(x, sigmoid, label="sigmoid")
plt.plot(x, step, linestyle="--", label="step_function")
plt.xlabel("x")
plt.ylabel("y")
plt.legend()
plt.show()