1.First of all 2. Operating environment 3. Body
Since this article forgets what I learned, the aim is to improve my ability to explain my own things while establishing what I have learned by writing it as a memorandum in this article. I want to do various things that Python can do, so I haven't decided on any tags other than Python.
--windows 10 (laptop)
--Read Deep Learning from scratch
Sites that I referred to when reading [github][https://github.com/oreilly-japan/deep-learning-from-scratch]
Chapter 1 Introduction to Python Here, from the installation of python, the basic operation of python and the explanation of libraries such as Numpy and Matplotlib are written.
Chapter 2 Perceptron The perceptron receives a plurality of signals and outputs one signal according to the contents. The output signal y is the input signal x1, x2, the weight w1, w2, and the threshold value θ.
f(x) = \left\{
\begin{array}{ll}
1 & (w1x1+w2x2\geq θ) \\
0 & (w1x1+w2x2 \lt θ)
\end{array}
\right.
Can be expressed as. In addition, AND gates, NAND gates, and OR gates are mounted using perceptrons.
def AND(x1,x2):
w1,w2,theta=0.5,0.5,0.7
tmp=x1*w1+x2*w2
if tmp>theta:
return 1
else:
return
Using a matrix, it becomes as follows.
import numpy as np
def AND(x1,x2):
w=np.array([0.5,0.5])
x=np.array([x1,x2])
b=-0.7
tmp=np.sum(w*x)+b
if tmp>0:
return 1
else:
return 0
If you enter appropriate values (x1, x2) = (0,0), (0,1), (1,1), (1,0) for x1, x2
a=AND(0,0)
b=AND(0,1)
c=AND(1,1)
d=AND(1,0)
print(a,b,c,d)
>> 0 0 1 0
It can be seen that it is operating correctly. Editing in the future
Recommended Posts