Last active
December 21, 2015 22:19
-
-
Save duckworthd/6374198 to your computer and use it in GitHub Desktop.
What does the output of an a Neural Network with soft-max and RBF kernels look like?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.stats import norm | |
import pylab as pl | |
def rbf(x, C, w): | |
y = [norm.pdf(np.linalg.norm(x - C[i]) ** 2.0, 0, 1) for i in range(C.shape[0])] | |
y = np.exp(y) / np.sum(np.exp(y)) | |
return w.dot(y) | |
if __name__ == '__main__': | |
C = np.random.randn(2, 2) | |
w = np.random.randn(2) | |
n = 200 | |
xs = ys = np.linspace(-2, 2, n) | |
xx, yy = np.meshgrid(xs, ys) | |
zz = np.zeros(xx.shape) | |
for i in range(n): | |
for j in range(n): | |
p = [xx[i,j], yy[i,j]] | |
zz[i,j] = rbf(p, C, w) | |
ax = Axes3D(pl.gcf()) | |
ax.plot_surface(xx, yy, zz) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment