LoginSignup
2
0

More than 3 years have passed since last update.

Python Programingの入門備忘録

Last updated at Posted at 2020-02-23

programをやる上での備忘録

目次

  1. はじめに
  2. 動作環境
  3. 本文

1. はじめに

 この記事は筆者が学習したことを忘れてしまうため、この記事に備忘録として記載することで学習した物事を定着させると同時に、自身の物事の説明する能力を向上させようという狙いがある。Pythonの出来ることをいろいろやりたいのでタグはPython以外に特に決めていない。

2. 動作環境

  • windows 10(ノートパソコン)
  • visual studio code (version 1.42.1)
  • anaconda 1.9.7 (pythonを動かすための仮想環境 VSCodeと連結)
  • ほか

3. 本文

  • ゼロから始めるDeepLearning を読み進める

読み進める上で参考にしたサイト
[github][https://github.com/oreilly-japan/deep-learning-from-scratch]

1章 Python入門
 ここはpythonのインストールから基本的なpythonの動作やNumpy,Matplotlibといったライブラリの説明などが書いてある。

2章 パーセプトロン
 パーセプトロンは複数の信号を受け取り、その内容により一つの信号を出力する。
パーセプトロンを入力信号x1,x2、重みw1,w2、閾値θを用いて出力信号yは

f(x) = \left\{
\begin{array}{ll}
1 & (w1x1+w2x2\geq θ) \\
0 & (w1x1+w2x2 \lt θ)
\end{array}
\right.

と表すことが出来る。
また、ANDゲートやNANDゲート、ORゲートをパーセプトロンを用いて実装し。

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 

行列を用いると以下の通りになる。

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

x1,x2に適当な値(x1,x2)=(0,0),(0,1),(1,1),(1,0)を入力すると

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

となり、正しく動作していることが分かる。
この先編集中

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0