This repository has been archived on 2020-04-25. You can view files and clone it, but cannot push or open issues or pull requests.
ml/nn/testnn.py
2020-02-23 22:14:06 +08:00

13 lines
282 B
Python
Executable File

#!/usr/bin/env python3
# coding: utf-8
import neuralNetwork as nn
import numpy as np
n = nn.NeuralNetwork([2, 2, 1], 'tanh')
x = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = np.array([0, 1, 1, 0])
n.fit(x, y)
for i in [[0, 0], [0, 1], [1, 0], [1, 1]]:
print(i, n.predit(i))