Skip to content

Instantly share code, notes, and snippets.

Joe Marino joelouismarino

Block or report user

Report or block joelouismarino

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gaussian_cdf_pytorch.py
import math
import torch
from torch.distributions import Normal
# standard univariate Gaussian (Normal)
mean = torch.zeros(1)
std = torch.ones(1)
# evaluate from -0.5 to 0.5
x_min = -0.5 * torch.ones(1)
View gaussian_log_prob_pytorch.py
import math
import torch
from torch.distributions import Normal
# standard univariate Gaussian (Normal)
mean = torch.zeros(1)
std = torch.ones(1)
# evaluate at the origin
value = torch.zeros(1)
View whiten.py
import numpy as np
def whiten(X, method='zca'):
"""
Whitens the input matrix X using specified whitening method.
Inputs:
X: Input data matrix with data examples along the first dimension
method: Whitening method. Must be one of 'zca', 'zca_cor', 'pca',
View 1d_non_gaussian_normalization.py
import numpy as np
n_samples = 500
mean_1 = 15
std_dev_1 = 5
mean_2 = -20
std_dev_2 = 3
X = np.concatenate([np.random.normal(mean_1, std_dev_1, n_samples / 2),
np.random.normal(mean_2, std_dev_2, n_samples / 2)], axis=0)
View 1d_gaussian_normalization.py
import numpy as np
n_samples = 500
mean = 15
std_dev = 5
X = np.random.normal(mean, std_dev, n_samples)
Z = (X - np.mean(X)) / np.std(X)
View googlenet_keras_results.py
keras_top_inds = keras_act[0].argsort()[::-1][:5]
zip(keras_act[0][keras_top_inds], labels[keras_top_inds])
View googlenet_caffe_labels.py
labels_file = caffe_root + 'data/ilsvrc12/synset_words.txt'
labels = np.loadtxt(labels_file, str, delimiter='\t')
caffe_top_inds = caffe_act[0].argsort()[::-1][:5]
zip(caffe_act[0][caffe_top_inds], labels[caffe_top_inds])
View googlenet_compare_act.py
caffe_act = net.blobs[layer_name].data
layer = googlenet.get_layer(name=layer_name)
keras_act = get_activations(googlenet, layer, img)
View googlenet_get_activations.py
import theano
def get_activations(model, layer, X_batch):
get_activations = theano.function([model.layers[0].input,K.learning_phase()], layer.output, allow_input_downcast=True)
activations = get_activations(X_batch,0)
return activations
View googlenet_caffe_run_model.py
net.blobs['data'].reshape(1, 3, 224, 224)
net.blobs['data'].data = img
output = net.forward()
You can’t perform that action at this time.