βshortの自堕落Diary

web関係や、プログラミングなどを扱う予定です。プランなど立てていないので、不定期投稿になります。

ReLU関数

ReLU関数

ReLUとは、Rectified Linear Unitの略である。
入力が0を超えていれば、その入力をそのまま出力し、0以下ならば0を出力する関数。

h(x)=\begin{cases}
& x \ \ (x>0) \\
& 0 \ \ (x\leq 0) \\
\end{cases}

import numpy as np 
import matplotlib.pylab as plt

def relu(x):
    return np.maximum(0,x)

x = np.arange(-5.0, 5.0, 0.1)
y = relu(x)

plt.plot(x, y, label = "LeRU")
plt.xlabel("x")
plt.ylabel("y")
plt.title("ReLU")
plt.show()

f:id:weblog2016it:20170715230154p:plain

参考


Pythonからはじめる数学入門


ゼロから作るDeep Learning ―Pythonで学ぶディープラーニングの理論と実装