Commit 368cc6ca authored by Eva Lina Fesefeldt's avatar Eva Lina Fesefeldt
Browse files

Aufgeräumt

parent fef81ce9

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
.vscode/
hessianlearn/
\ No newline at end of file
hessianlearn/
TicTacToe/Data_Set/__pycache__
TicTacToe/Hesse-Matrix/__pycache__
TicTacToe/Hesse-Matrix_Eigenwerte/__pycache__
TicTacToe/Lanczos-Ritz/__pycache__
TicTacToe/Vergleich_Analytische_Ableitung/__pycache__
TicTacToe/Vergleich_Optimizer/__pycache__
\ No newline at end of file
#!/bin/bash -l
#SBATCH -p gpu
#SBATCH --ntasks 1
#SBATCH --cpus-per-task 4
#SBATCH --gres gpu:2
#SBATCH --constraint gpu_k20
#SBTACH --mem-per-cpu 2000
#SBATCH --time 24:00:00
#SBATCH --mail-type END,FAIL,REQUEUE
#SBATCH --mail-user eva.fesefeldt@tuhh.de
conda activate tf-gpu
python main.py
exit
......@@ -3,7 +3,6 @@ import matplotlib as mpl
import matplotlib.pyplot as plt
import math
from generate_dataset import *
import tikzplotlib
def imshow_zero_center(image, n):
lim = tf.reduce_max(abs(image))
......@@ -37,7 +36,8 @@ def show_eigenvalues_semilogx_complex_plane(A, n):
# Visualisieren des Feldes
def show_fields(X, labels, n):
#plt.rcParams.update({"text.usetex": True, "font.family": "sans-serif", "font.sans-serif": ["Helvetica"]})
plt.figure(figsize=(20, 4))
mpl.rcParams.update({'font.size': 8})
plt.figure(figsize=(7, 7))
ncols = 3
nrows = math.ceil(n / ncols)
for i in range(n):
......@@ -50,10 +50,11 @@ def show_fields(X, labels, n):
title = 'Schwarz gewinnt'
if labels[i,2] == 1:
title = 'Unentschieden'
ax.set_title(r'unentschieden')
ax.set_title(title)
ax.get_xaxis().set_visible(False)
ax.get_yaxis().set_visible(False)
plt.savefig("./figures/dataset.pdf")
plt.show()
def driver_show_fields():
set, labels = generate_tictactoe()
......
......@@ -629,6 +629,7 @@ if __name__ == "__main__":
# Gradient & Hesse-Matrix wie per Hand berechnet
gradient_hand, hessian_hand = grad_and_hesse_matrix(model, train_set, train_labels)
# vergleichende Plots
imshow_zero_center(hessian_hand - h_mat_keras.numpy(), "Hesse-Matrix n=1 analytisch vs. AD Absoluter Fehler")
imshow_zero_center((hessian_hand - h_mat_keras.numpy())/h_mat_keras.numpy(), "Hesse-Matrix n=1 analytisch vs. AD Relativer Fehler")
\ No newline at end of file
imshow_zero_center((hessian_hand - h_mat_keras.numpy())/h_mat_keras.numpy(), "Hesse-Matrix n=1 analytisch vs. AD Relativer Fehler")
......@@ -63,11 +63,11 @@ hessian_nested_tapes = matrix_trainable_shape_to_flat_shape(model, h)
# Vektor zum Testen festlegen
# Einheitsvektor
test_vector = tf.eye(number_of_parameters, number_of_parameters)[:,15]
#test_vector = tf.eye(number_of_parameters, number_of_parameters)[:,15]
#Für voll besetzten Vektor hier auskommentieren
#test_vector_numpy = np.load("random_residuum.npy").astype(float)
#test_vector = tf.constant(test_vector, dtype='float32')
test_vector_numpy = np.load("random_residuum.npy").astype(float)
test_vector = tf.constant(test_vector_numpy, dtype='float32')
test_vector_trainable_shape = vector_flat_shape_to_trainable_shape(test_vector)
......@@ -88,6 +88,10 @@ Hv_BOF_vec = vector_trainable_shape_to_flat_shape(Hv_BOF)
Hv_BOB_vec = vector_trainable_shape_to_flat_shape(Hv_BOB)
if size_hidden_layer == 1:
np.save("Hv_nested_tapes_n1.npy", Hv_nested_tapes)
np.save("Hv_BOF_n1.npy", Hv_BOF_vec)
np.save("Hv_analytisch.npy", Hv)
vecshow_zero_center(np.reshape((Hv_nested_tapes-Hv)/Hv, (16,1)), "Relativer Fehler Hv Nested Gradient zu Hv analytisch")
vecshow_zero_center(np.reshape((Hv_BOF_vec-Hv)/Hv, (16,1)), "Relativer Fehler BOF zu Hv analytisch")
vecshow_zero_center(np.reshape((Hv_BOB_vec-Hv)/Hv, (16,1)), "Relativer Fehler BOB zu Hv analytisch")
......
import numpy as np
import matplotlib.pyplot as plt
Hv = np.load("results/Hv_analytisch.npy").reshape((16,1))
Hv_BOF = np.load("results/Hv_BOF_n1.npy").reshape((16,1))
Hv_nested_tapes = np.load("results/Hv_nested_tapes_n1.npy").reshape((16,1))
fig, (ax1, ax2, ax3) = plt.subplots(1,3, sharey=True, figsize= (5,5))
fig.suptitle("")
ax1.imshow(Hv)
ax2.imshow(Hv_BOF)
ax3.imshow(Hv_nested_tapes)
#fig.colorbar()
plt.show()
\ No newline at end of file
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