Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import matplotlib.pyplot as plt
- import numpy as np
- def referencial():
- fig = plt.figure()
- #https://matplotlib.org/stable/api/figure_api.html?highlight=add_subplot#matplotlib.figure.Figure.add_subplot
- theAxes = fig.add_subplot(1, 1, 1) #controls the organization of the figure (e.g. 1x1, 2x2) and the index of the 1st contained sub figure, if not 1x1
- theAxes.spines['left'].set_position('center') #forces the left spine to be at the center
- theAxes.spines['bottom'].set_position('zero') #forces the bottom spine to be plotted at zero
- theAxes.spines['right'].set_color('none') #makes the right spine invisible
- theAxes.spines['top'].set_color('none') #makes the top spine invisible
- theAxes.xaxis.set_ticks_position('bottom') # controls where the x points' labels are written
- theAxes.yaxis.set_ticks_position('left') #controls where the y points' labels are written
- # def referencial
- """
- rispid limit
- x<0 ; y=-1
- x>0 ; y=1
- """
- x_axis_xlt0 = np.linspace(-5, 0, 100)
- x_axis_xgt0 = np.linspace(0, 5, 100)
- y_axis_xlt0 = np.linspace(-1, -1, 100)
- y_axis_xgt0 = np.linspace(1, 1, 100)
- referencial()
- plt.plot(x_axis_xlt0, y_axis_xlt0)
- plt.plot(x_axis_xgt0, y_axis_xgt0)
- plt.show()
- # TODO 1
- """
- ramp function = relu
- x<0 ; y=0
- 0<=x<=1 ; y=x
- x>1 ; y=1
- """
- # TODO 2
- """
- sigmoid
- y = 1/(1+e**-x)
- """
- x_axis = np.linspace(-5, 5, 100)
- y_axis = 1/(1+np.e**(-1*x_axis))
- referencial()
- plt.plot(x_axis, y_axis)
- plt.show()
- # TODO 3
- """
- hyperbolic tangent
- (e**x - e**-x) / (e**x + e**-x)
- """
- x_axis = np.linspace (-10, 10, 1000)
- y_axis = (np.e**x_axis - np.e**(-1*x_axis)) / (np.e**x_axis + np.e**(-1*x_axis))
- referencial()
- plt.plot(x_axis, y_axis)
- plt.title("Hyperbolic tangent")
- plt.show()
- # TODO 4
Advertisement
Add Comment
Please, Sign In to add comment