コード例 #1
0
def forward(network, x):
    W1, W2, W3 = network['W1'], network['W2'], network['W3']
    b1, b2, b3 = network['b1'], network['b2'], network['b3']

    a1 = c.np.dot(x, W1) + b1
    z1 = sig.sigmoid(a1)
    a2 = c.np.dot(z1, W2) + b2
    z2 = sig.sigmoid(a2)
    a3 = c.np.dot(z2, W3) + b3
    Y = identity_function(a3)

    return Y
コード例 #2
0
def predict(network, x):
    W1, W2, W3 = network['W1'], network['W2'], network['W3']
    b1, b2, b3 = network['b1'], network['b2'], network['b3']

    a1 = c.np.dot(x, W1) + b1
    z1 = sig.sigmoid(a1)
    a2 = c.np.dot(z1, W2) + b2
    z2 = sig.sigmoid(a2)
    a3 = c.np.dot(z2, W3) + b3
    y = soft.softmax(a3)

    return y
コード例 #3
0
    def predict(self, x):
        W1, W2 = self.params['W1'], self.params['W2']
        b1, b2 = self.params['b1'], self.params['b2']

        a1 = c.np.dot(x, W1) + b1
        z1 = sig.sigmoid(a1)
        a2 = c.np.dot(z1, W2) + b2
        y = softmax(a2)

        return y
コード例 #4
0
from lib import common as c
from lib import sigmoid as sig

X = c.np.array([1.0, 0.5])
W1 = c.np.array([[0.1, 0.3, 0.5], [0.2, 0.4, 0.6]])
B1 = c.np.array([0.1, 0.2, 0.3])
print(X.shape)
print(W1.shape)
print(B1.shape)

A1 = c.np.dot(X, W1) + B1
print(A1)

Z1 = sig.sigmoid(A1)
W2 = c.np.array([[0.1, 0.4], [0.2, 0.5], [0.3, 0.6]])
B2 = c.np.array([0.1, 0.2])

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

A2 = c.np.dot(Z1, W2) + B2
print(A2)

Z2 = sig.sigmoid(A2)
print(Z2)


def identity_function(x):
    return x