In [1]:
# Explanation / Example Graphs
# RevereseLearning, 2017
In [2]:
import plotly
import plotly.graph_objs as go
import numpy as np
plotly.offline.init_notebook_mode()
In [3]:
# Sigmoid
def Sigmoid():
x = np.linspace(-5, 5, 100)
y = 1/(1+np.exp(-x))
graph = go.Scatter(x = x, y = y, line = dict(width = 5))
layout = go.Layout(title = "Sigmoid",
xaxis = dict(title = "Input"),
yaxis = dict(title = "Output"))
fig = go.Figure(data = [graph], layout = layout)
plotly.offline.iplot(fig)
Sigmoid()
In [4]:
# Restricted
def Restricted():
x = np.linspace(-10, 10, 100)
r1 = (40 - 10)/(1+np.exp(-x)) + 10
g1 = go.Scatter(x = x, y = r1, name = "Restricted (10 < x < 40)",
line = dict(width = 5))
r2 = ((-10) - (-20))/(1+np.exp(-x)) + (-20)
g2 = go.Scatter(x = x, y = r2, name = "Restricted (-20 < x < -10)",
line = dict(width = 5))
inp = go.Scatter(x = x, y = x, name = "Unrestricted",
line = dict(width = 5))
layout = go.Layout(title = "Range Restricted",
xaxis = dict(title = "Input"),
yaxis = dict(title = "Ouput"))
fig = go.Figure(data = [g1, g2, inp], layout = layout)
plotly.offline.iplot(fig)
Restricted()
In [5]:
def TopByInput():
tSpace = np.linspace(0, 10, 100)
iSpace = np.linspace(-30, 30, 100)
top, inp = np.meshgrid(tSpace, iSpace)
bottom = 0
restricted = (top - bottom)/(1 + np.exp(-1 * inp)) + bottom
g = go.Surface(x = inp, y = top, z = restricted)
layout = go.Layout(xaxis = dict(title = "Input"),
yaxis = dict(title = "Top"))
fig = go.Figure(data = [g], layout = layout)
plotly.offline.iplot(fig)
TopByInput()
In [14]:
def TopBottom():
tSpace = np.linspace(0, 10, 100)
bSpace = np.linspace(-10, 0, 100)
top, bottom = np.meshgrid(tSpace, bSpace)
inp = 0
restricted = (top - bottom)/(1 + np.exp(-1 * inp)) + bottom
g = go.Surface(x = bottom, y = top, z = restricted)
layout = go.Layout(xaxis = dict(title = "Bottom"),
yaxis = dict(title = "Top"))
fig = go.Figure(data = [g], layout = layout)
plotly.offline.iplot(fig)
TopBottom()
In [17]:
def All():
tSpace = np.linspace(0, 10, 50)
bSpace = np.linspace(-10, 0, 50)
iSpace = np.linspace(-10, 10, 50)
top, bottom, inp = np.meshgrid(tSpace, bSpace, iSpace)
restricted = (top - bottom)/(1 + np.exp(-1 * inp)) + bottom
g = go.Surface(x = bottom, y = top, z = inp, surfacecolor = restricted)
fig = go.Figure(data = [g], layout = layout)
plotly.offline.iplot(fig)
All()
In [ ]: