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 matplotlib import pyplot as plt | |
mean = [0, 0] | |
cov = [[1., .5], [.5, 1.]] | |
m = 128 | |
X = np.random.multivariate_normal(mean, cov, m) | |
cov = np.cov(X.T) |
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
#!/bin/bash | |
## This gist contains step by step instructions to install cuda v9.0 and cudnn 7.2 in ubuntu 18.04 | |
### steps #### | |
# verify the system has a cuda-capable gpu | |
# download and install the nvidia cuda toolkit and cudnn | |
# setup environmental variables | |
# verify the installation | |
### |
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 imageio | |
import numpy as np | |
from skimage.transform import resize | |
import tensorflow as tf | |
# obviously requires a session to run | |
outs = sess.run(conv0, feed_dict={input : img}) | |
for i in range(32): | |
# this will size up the filter output to (200, 200) and save it as .png | |
imageio.imwrite(str(i) + '.png', resize((outs[0,:,:,i] * 200).astype(np.uint8), (200, 200))) |
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 | |
import matplotlib.pyplot as plt | |
def softmax(x, beta=1.0): | |
return np.exp(beta * x) / np.sum(np.exp(beta * x)) | |
def softargmax(x, beta=1.0): | |
return np.sum((np.exp(beta * x) / np.sum(np.exp(beta * x))) * np.arange(len(x))) |