Created
October 11, 2016 19:39
-
-
Save aecker/e8f19c489e79944bd5fecff4e880a817 to your computer and use it in GitHub Desktop.
Calculation of explainable variance etc.
This file contains 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
# 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 | |
# Calculate fraction of explainable variance explained | |
# Linden & Sahani calculate it in a different way, but the result is the same. | |
# I'm not 100% sure why it comes out the same, though. | |
obs_var = (responses_val_raw.var(axis=0, ddof=1) / reps).mean(axis=0) # Linden & Sahani call this 'noise power' | |
total_var = responses_val_raw.mean(axis=0).var(axis=0, ddof=1) | |
explainable_var = total_var - obs_var # Linden & Sahani call this 'signal power' | |
mse = ((prediction - responses_val_raw.mean(axis=0)) ** 2).mean(axis=0) | |
eve = (total_var - mse) / explainable_var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment