# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Inception
#     language: python
#     name: inception
# ---

# + [markdown] toc="true"
# # Table of Contents
#  <p>

# +
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.ticker import FormatStrFormatter
plt.style.use('ggplot')

     
# Update parameters for matplotlib
params = {"text.usetex": True,
          'font.size' : 12,
          "text.latex.unicode": True,
          "axes.unicode_minus": True,
          'xtick.color': 'black',
          'ytick.color': 'black',
          'axes.labelcolor': "black"
         
         }
plt.rcParams.update(params)
#mpl.rcParams['axes.linewidth'] = 0.3
#mpl.rcParams['axes.edgecolor'] = grey
#mpl.rcParams['xtick.color'] = grey
#mpl.rcParams['ytick.color'] = grey
#mpl.rcParams['axes.labelcolor'] = "black"

# +


fig, axes = plt.subplots(ncols=3, nrows=1)

left  = 0.125  # the left side of the subplots of the figure
right = 0.9    # the right side of the subplots of the figure
bottom = 0.1   # the bottom of the subplots of the figure
top = 0.9      # the top of the subplots of the figure
wspace = 0.35   # the amount of width reserved for space between subplots,
               # expressed as a fraction of the average axis width
hspace = 0.2   # the amount of height reserved for space between subplots,
               # expressed as a fraction of the average axis height
plt.subplots_adjust(left, bottom, right, top,
                wspace, hspace)
# fig height and width in inch
fig.set_figheight(7.226/4)
fig.set_figwidth(7.226)
ax1, ax2, ax3 = axes.ravel()


x = np.linspace(-6, 6)


ax1.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax1.set_xlabel('$z$')
ax1.set_ylabel('$\sigma(z)$')
ax1.set_title('Sigmoid',fontsize=12)
ax1.plot(x, 1 / (1 + np.exp(-x)),color = 'blue' )
ax1.text(-6.5,0.8,r'$ \sigma(z) = \frac{1}{1+e^{-z}}$')



ax2.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax2.set_xlabel('$z$')
ax2.set_ylabel('$\sigma(z)$')
ax2.set_title('TanH',fontsize=12)
ax2.plot(x, np.tanh(x) ,color = 'blue' )
ax2.text(-6.5,0.8,r'$ \sigma(z) = \!\mathrm{tanh}(z)$',fontsize=10)





ax3.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax3.set_xlabel('$z$')
ax3.set_ylabel('$\sigma(z)$')
ax3.set_title('ReLU',fontsize=12)
ax3.plot(x, np.maximum(x, 0) ,color = 'blue' )
ax3.text(-5,4.5,r'$\sigma (z) = \mathrm{max}(z,0)$',fontsize=10)
#\left\{\begin{array}{lll} 0 &  \textrm{if} & z < 0 \\z & \textrm{if} & z \geq 0\\ \end{array}\right. 
plt.draw()
plt.savefig("ActivationFunction.pdf", 
            #This is simple recomendation for publication plots
            dpi=1000, 
            # Plot will be occupy a maximum of available space
            bbox_inches='tight', 
            )
plt.show()
# -



StarcoderdataJupyterScriptsDedupFiltered