Пример #1
0
X = np.random.rand(N) * 2.0 * np.pi
Y = np.sin(X)

training_data = [[np.array([[x]]), y] for x, y in zip(X, Y)]

input_size = 1
hidden_size = 10
hidden_layer_num = 10
output_size = 1

Neural_structure = [input_size]
for l in range(hidden_layer_num):
    Neural_structure.append(hidden_size)
Neural_structure.append(output_size)

net = Network.Network(Neural_structure, cost=Network.CrossEntropyCost())

print('Layer # = %d' % (hidden_layer_num))
print('NN structure:', Neural_structure)

epochs_num = 50
mini_batch_size = 10
eta = 0.1

ims = []

Y_plot = Y[np.argsort(X)]
X_plot = np.sort(X)

for epochs in range(50):
    net.SGD(