Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c2e8582

Browse files
authoredJul 18, 2019
Travis CI: Add pytest --doctest-modules neural_network (TheAlgorithms#1028)
* neural_network/perceptron.py: Add if __name__ == '__main__': * Remove tab indentation * Add neural_network to the pytests
1 parent 4658f4a commit c2e8582

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed
 

‎.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ script:
2626
linear_algebra_python
2727
matrix
2828
networking_flow
29+
neural_network
2930
other
3031
project_euler
3132
searches

‎neural_network/perceptron.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
'''
22
3-
Perceptron
4-
w = w + N * (d(k) - y) * x(k)
3+
Perceptron
4+
w = w + N * (d(k) - y) * x(k)
55
6-
Using perceptron network for oil analysis,
7-
with Measuring of 3 parameters that represent chemical characteristics we can classify the oil, in p1 or p2
8-
p1 = -1
9-
p2 = 1
6+
Using perceptron network for oil analysis,
7+
with Measuring of 3 parameters that represent chemical characteristics we can classify the oil, in p1 or p2
8+
p1 = -1
9+
p2 = 1
1010
1111
'''
1212
from __future__ import print_function
@@ -113,12 +113,13 @@ def sign(self, u):
113113

114114
exit = [-1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1]
115115

116-
network = Perceptron(sample=samples, exit = exit, learn_rate=0.01, epoch_number=1000, bias=-1)
116+
if __name__ == '__main__':
117+
network = Perceptron(sample=samples, exit = exit, learn_rate=0.01, epoch_number=1000, bias=-1)
117118

118-
network.training()
119+
network.training()
119120

120-
while True:
121-
sample = []
122-
for i in range(3):
123-
sample.insert(i, float(input('value: ')))
124-
network.sort(sample)
121+
while True:
122+
sample = []
123+
for i in range(3):
124+
sample.insert(i, float(input('value: ').strip()))
125+
network.sort(sample)

0 commit comments

Comments
 (0)
Please sign in to comment.