<jupyter_start><jupyter_text>Activation functions ReLU$f(x) = max(0,s)$<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
# better plots
import seaborn as sns
sns.set()
def max_relu(x):
  return max(x, 0)
# test max_relu
for i in [-10, -5, 7, -4]:
  print(max_relu(i))

# create plot
# from -10 to 10, step 0.1
data = np.arange(-10, 10, 0.1)
y_relu = [max_relu(x) for x in data]

plt.plot(data, y_relu)
plt.title("ReLU function")<jupyter_output><empty_output><jupyter_text>Sigmoid function$f(x) = \frac{1}{1+e^{-x}}$<jupyter_code>def sigmoid(x):
  return 1.0 / (1 + np.exp(-x))
y_sigmoid = [sigmoid(x) for x in data]
plt.plot(data, y_sigmoid)
plt.title("sigmoid function")<jupyter_output><empty_output><jupyter_text>Softmax$S(y_i) = \frac{e^{y_i}}{\sum_{j=1}^{i}e^{y_j}}$<jupyter_code>data = np.random.randn(3, 5)
data
import pandas as pd
df = pd.DataFrame(data)
df
# pozbylismy sie wartosci ujemnych
np.exp(df)
# sumujemy kolumny
np.sum(np.exp(df), axis=0)
# pstwa przynaleznosci do danej klasy (dla 4 punktow)
res = np.exp(df) / np.sum(np.exp(df), axis=0)
res
# proawopodobienstwa przynalznosci do danej klasy (0 lub 1 lub 2)
np.sum(res, axis=0)<jupyter_output><empty_output><jupyter_text>Tanh$tanh(x)=\frac{e^x-e^{-x}}{e^x+e^{-x}}$<jupyter_code>def tanh(x):
  return (np.exp(x) - np.exp(-x)) / (np.exp(x) + np.exp(-x))
for i in [-2, -1, 0, 1, 2]:
  print(tanh(i))
data = np.arange(-10, 10, 0.1)
y_tanh = [tanh(x) for x in data]

plt.plot(data, y_tanh)
plt.title("Tanh function")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18754098360655738, 'fraction_numerical': 0.029508196721311476, 'mean_word_length': 5.466101694915254, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '222851', 'license': 'MIT', 'n_tokens_mistral': 756, 'n_tokens_neox': 719, 'n_words': 146, 'path': 'activation_functions.ipynb', 'repo_name': 'zuza3012/Deep_Learning', 'size': '1525'}