コード例 #1
0
ファイル: main.py プロジェクト: origapepe/Machine-Learning
def Dtanh(y):
    return 1-y*y


def linear(x):
    return x


def Dlinear(y):
    return 1


nn = NeuralNetwork(1, 1)

nn.add(5, [tanh, Dtanh])
nn.add(5, [tanh, Dtanh])
nn.init([linear, Dlinear])

n = 25000
cost = []

for i in range(n):
    index = np.random.randint(0, N)
    x = data[index][0]
    y = data[index][1]
    c = nn.cost(x, y)
    cost.append(c)
    nn.train(x, y)

    if i % 100 == 0:
コード例 #2
0
from nn import NeuralNetwork

import numpy as np

# lst = ['a', 'b', 'c']

# pool = cycle(lst)

# for item in pool:
# 	print(item)

X = np.array([[0, 81, 75, 0]])
y = np.array([[1]])
nn = NeuralNetwork(X,y)
nn.add(7)

nn.fit(12,100,0.5,0.001)