import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = np.array([1,-1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.ylim(-2.2, +2.2)
plt.plot(x,'o-')
plt.title('input x')
plt.show
plt.subplot(222)
plt.ylim(-2.2, +2.2)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.ylim(-2.2, +2.2)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-2.2, +2.2)
plt.ylim(-2.2, +2.2)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = np.array([1,0,-1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.ylim(-2.2, +2.2)
plt.plot(x,'o-')
plt.title('input x')
plt.ylim(-2.2, +2.2)
plt.show
plt.subplot(222)
plt.ylim(-2.2, +2.2)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.ylim(-2.2, +2.2)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-2.2, +2.2)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-2.,vmax=2.))
import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = np.array([-1,2,-1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.ylim(-4.4, +4.4)
plt.plot(x,'o-')
plt.title('input x')
plt.show
plt.subplot(222)
plt.ylim(-4.4, +4.4)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.ylim(-4.4, +4.4)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-4.4, +4.4)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-4.,vmax=4.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-4.,vmax=4.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-4.,vmax=4.))
import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = np.array([-1,5,-1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.ylim(-7.7, +7.7)
plt.plot(x,'o-')
plt.title('input x')
plt.show
plt.subplot(222)
plt.ylim(-7.7, +7.7)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.ylim(-7.7, +7.7)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-7.7, +7.7)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-7.,vmax=7.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-7.,vmax=7.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-7.,vmax=7.))
import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = 0.25*np.array([1,2,1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.plot(x,'o-')
plt.title('input x')
plt.show
plt.subplot(222)
plt.ylim(-1.1,1.1)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-1.1,1.1)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))
import numpy as np
x = np.array([1,0.95,1,0.95,1,1.05,1,0,-1,-1,-1,-1.05,-.95,-1,-.95,-1.05,0,1,0,-1,0,1,1,1,1,1,1,1,1,1,-1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,-1])
w = (1/float(5))*np.array([1,1,1,1,1])
a = np.convolve(x,np.flip(w))
import matplotlib as mpl
import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
fig=plt.figure(figsize=(12, 12), dpi= 80, facecolor='w', edgecolor='k')
plt.subplot(221)
plt.plot(x,'o-')
plt.title('input x')
plt.show
plt.subplot(222)
plt.ylim(-1.1,1.1)
plt.xlim(-1, x.size)
plt.plot(w,'o-')
plt.title('filter w')
plt.show
plt.subplot(223)
plt.plot(a[w.size-1:-w.size],'o-')
plt.title('output a=conv(x,w)')
plt.show
plt.subplot(224)
plt.ylim(-1.1,1.1)
plt.plot(0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size])),'o-')
plt.title('output z=ReLU(a)')
plt.show
plt.matshow([x],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))
plt.matshow([a[w.size-1:-w.size]],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))
plt.matshow([0.5*(a[w.size-1:-w.size]+np.absolute(a[w.size-1:-w.size]))],cmap='bwr',norm = mpl.colors.Normalize(vmin=-1.,vmax=1.))