LoginSignup
1
0

More than 3 years have passed since last update.

圧倒的非プログラマーがDeep Learningを学ぶ 関数編

Last updated at Posted at 2019-08-22

(2019.08.23)(仮)

ニューラルネットワーク

関数の実装

import numpy as np
import matplotlib.pylab as plt

シグモイド関数

def sigmoid(x):
  return 1/(1+np.exp(-x))

ステップ関数

def step_function(x):
  y = x > 0
  return y.astype(np.int)

NumPyの配列を引数とする使い方で実装

def step_function(x):
  if x > 0:
    return 1
  else:
    return 0

この実装の場合、引数のxは実数(float型)しか入力できない。

astype( )メソッドでは、引数に希望する型(今回はint型*)を指定できる。

*Pythonではブーリアン型(真偽)をint型に変換すると、Trueは1、Falseは0となる。
(仮)

1
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
1
0