A basic implementation of logical 'and' in a Perceptron
$ python3 -m venv venv
$ source ./venv/bin/activate
$ pip install -r requirements.txt
$ python3 Perceptron_Test.py
$ pycodestyle *.py
Loosely based on Thomas Countz' implementation from here: https://gist.github.com/Thomascountz/77670d1fd621364bc41a7094563a7b9c
(base) shirish@***************:workarea/perceptron-boolean-and ‹master*›$
------------------------------------------------------------------------
x1 x2 LR t sum act dw1 dw2 db w1 w2 b
------------------------------------------------------------------------
Epoch-1
1 1 0.01 1 0 0 0.01 0.01 0.01 0.01 0.01 0.01
1 0 0.01 0 0.02 1 0.0 0.01 0.0 0.0 0.01 0.0
0 1 0.01 0 0.01 1 0.0 0.0 -0.01 0.0 0.0 -0.01
0 0 0.01 0 -0.01 0 0.0 0.0 -0.01 0.0 0.0 -0.01
------------------------------------------------------------------------
x1 x2 LR t sum act dw1 dw2 db w1 w2 b
------------------------------------------------------------------------
Epoch-2
1 1 0.01 1 -0.01 0 0.01 0.01 0.0 0.01 0.01 0.0
1 0 0.01 0 0.01 1 0.0 0.01 -0.01 0.0 0.01 -0.01
0 1 0.01 0 0.0 0 0.0 0.01 -0.01 0.0 0.01 -0.01
0 0 0.01 0 -0.01 0 0.0 0.01 -0.01 0.0 0.01 -0.01
...
Epoch-99
1 1 0.01 10.009999999999999998 1 0.01 0.02 -0.02 0.01 0.02 -0.02
1 0 0.01 0 -0.01 0 0.01 0.02 -0.02 0.01 0.02 -0.02
0 1 0.01 0 0.0 0 0.01 0.02 -0.02 0.01 0.02 -0.02
0 0 0.01 0 -0.02 0 0.01 0.02 -0.02 0.01 0.02 -0.02
------------------------------------------------------------------------
x1 x2 LR t sum act dw1 dw2 db w1 w2 b
------------------------------------------------------------------------
Epoch-100
1 1 0.01 10.009999999999999998 1 0.01 0.02 -0.02 0.01 0.02 -0.02
1 0 0.01 0 -0.01 0 0.01 0.02 -0.02 0.01 0.02 -0.02
0 1 0.01 0 0.0 0 0.01 0.02 -0.02 0.01 0.02 -0.02
0 0 0.01 0 -0.02 0 0.01 0.02 -0.02 0.01 0.02 -0.02
evaluate 1 1 , result: (1, 0.009999999999999998)
evaluate 0 1 , result: (0, 0.0)
evaluate 1 0 , result: (0, -0.01)
evaluate 0 0 , result: (0, -0.02)
.
----------------------------------------------------------------------
Ran 1 test in 0.329s
OK