Commit fa871578 authored by Lukas Wolf's avatar Lukas Wolf
Browse files

plotted angle distribution

parent 053f8caf
......@@ -20,4 +20,5 @@ labels.txt
preds.txt
angle_comparison.ipynb
retrain_model.ipynb
conv_analysis.ipynb
\ No newline at end of file
conv_analysis.ipynb
./scripts/*
\ No newline at end of file
""""
This script cannot be run in a notebook as it uses too much memory for loading the dataset
Run it on arton with 1 gpu
CHOOSE:
1. Dataset that we wan't to load
2. Model that we wan't to use
"""
MODEL_PATH = "./archive_runs/calib_task/angle_reg/1618833252_cnn_angle-reg_fix_sacc_fix_calibration_task/cnn_best_model.h5"
FILENAME = "angle_distributions_.png"
import numpy as np
from utils.losses import angle_loss
from tensorflow import keras
import matplotlib.pyplot as plt
# Load the precomputed data
targets = np.load("./data/precomputed/calibration_task/all_fix_sacc_fix_y.npy")
X = np.load("./data/precomputed/calibration_task/all_fix_sacc_fix_X.npy")
# Load the model
model = keras.models.load_model(MODEL_PATH, compile=False)
model.compile(loss=angle_loss, optimizer=keras.optimizers.Adam(learning_rate=1e-5))
# Predict on dataset
preds = model.predict(X)
# Plot the two histograms
fig, axs = plt.subplots(2, 1, constrained_layout=True)
axs[0].hist(targets, bins=100)
axs[0].set_title("Ground truth angle distribution")
#axs[0].set_xlabel("Angle in rad")
axs[0].set_ylabel("Samples")
axs[0].set_xlim([-4,4])
axs[1].hist(preds, bins=100)
axs[1].set_title("Prediction angle distribution")
axs[1].set_xlabel("Angle in rad")
axs[1].set_ylabel("Samples")
axs[1].set_xlim([-4,4])
# chosse a filename
fig.savefig(FILENAME, facecolor='white')
#plt.show()
\ No newline at end of file
......@@ -482,8 +482,8 @@ def get_fix_sacc_fix_data(verbose=True):
logging.info(X.shape)
# Save the precomputed data for future usage
np.save("./data/precomputed/calibration_task/fix_sacc_fix_X", X)
np.save("./data/precomputed/calibration_task/fix_sacc_fix_y", y)
#np.save("./data/precomputed/calibration_task/all_fix_sacc_fix_X", X)
#np.save("./data/precomputed/calibration_task/all_fix_sacc_fix_y", y)
return X, y
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment