Skip to content

Instantly share code, notes, and snippets.

View zym1010's full-sized avatar

Yimeng Zhang zym1010

View GitHub Profile
@zym1010
zym1010 / ve.py
Created November 21, 2016 17:36 — forked from aecker/ve.py
Calculation of explainable variance etc.
# Load data
responses_val_raw = np.load(os.path.join(path, 'raw_validation_set.npy'))
prediction = mymodel.prediction()
reps, num_imgs, num_neurons = responses_val_raw.shape
# Calculate normalized noise power
obs_var_raw = (responses_val_raw.var(axis=0, ddof=1)).mean(axis=0)
total_var_raw = responses_val_raw.reshape([-1, num_neurons]).var(axis=0, ddof=1)
nnp = obs_var / total_var
@zym1010
zym1010 / discrete_cmap.py
Created July 1, 2016 01:22 — forked from jakevdp/discrete_cmap.py
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""