<jupyter_start><jupyter_text>[Python で 超実習ディープラーニング](https://www.seminar-info.jp/entry/seminars/view/1/4174)実践！ 強化学習・画像認識・自然言語処理・ロボティクス![](https://www.seminar-info.jp/entry/img/logo_ov.jpg)<NAME>, all rights reserved.Date: 15/Mar/2019 MIT license<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

## [Original](https://github.com/alrojo/tensorflow-tutorial/blob/master/lab1_FFN/lab1_FFN.ipynb)

# PLOT OF DIFFERENT OUTPUT USNITS
x = np.linspace(-6, 6, 100)
relu = lambda x: np.maximum(0, x)
leaky_relu = lambda x: np.maximum(0, x) + 0.1*np.minimum(0, x) 
elu = lambda x: (x > 0)*x + (1 - (x > 0))*(np.exp(x) - 1) 
sigmoid = lambda x: (1+np.exp(-x))**(-1)
def softmax(w, t = 1.0):
    e = np.exp(w)
    dist = e / np.sum(e)
    return dist
x_softmax = softmax(x)

plt.figure(figsize=(6,6))
plt.plot(x, relu(x), label='ReLU', lw=2)
plt.plot(x, leaky_relu(x), label='Leaky ReLU',lw=2)
plt.plot(x, elu(x), label='Elu', lw=2)
plt.plot(x, sigmoid(x), label='Sigmoid',lw=2)
plt.plot(x, np.tanh(x), label='tanh', lw=2)  # added by Asakawa
plt.legend(loc=2, fontsize=16)
plt.title('Non-linearities', fontsize=20)
plt.ylim([-2, 5])
plt.xlim([-6, 6])

# softmax
# assert that all class probablities sum to one
print(np.sum(x_softmax))
assert abs(1.0 - x_softmax.sum()) < 1e-8<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1980421686746988, 'fraction_numerical': 0.038403614457831324, 'mean_word_length': 4.959641255605381, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 3, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '496047', 'license': 'MIT', 'n_tokens_mistral': 676, 'n_tokens_neox': 631, 'n_words': 112, 'path': 'notebooks/2019si_activaton_functions.ipynb', 'repo_name': 'ShinAsakawa/2019seminar_info', 'size': '1335'}