Commit 09cf74ce authored by Eva Lina Fesefeldt's avatar Eva Lina Fesefeldt
Browse files

Figures Eigenwerte korrigiert

parent eff0cce1
TicTacToe/figures/hessematrix_n5.png

29.2 KB | W: | H:

TicTacToe/figures/hessematrix_n5.png

37.3 KB | W: | H:

TicTacToe/figures/hessematrix_n5.png
TicTacToe/figures/hessematrix_n5.png
TicTacToe/figures/hessematrix_n5.png
TicTacToe/figures/hessematrix_n5.png
  • 2-up
  • Swipe
  • Onion skin
TicTacToe/figures/hessematrix_n50.png

67.7 KB | W: | H:

TicTacToe/figures/hessematrix_n50.png

119 KB | W: | H:

TicTacToe/figures/hessematrix_n50.png
TicTacToe/figures/hessematrix_n50.png
TicTacToe/figures/hessematrix_n50.png
TicTacToe/figures/hessematrix_n50.png
  • 2-up
  • Swipe
  • Onion skin
n = 2 Loss: 0.59798056
n = 5 Loss: 0.17916788
n = 10 Loss: 0.00568075
n = 20 Loss: 3.3272834e-05
n = 30 Loss: 1.9049863e-06
n = 50 Loss: 7.365435e-07
n = 100 Loss: 5.6624435e-07
......@@ -14,7 +14,14 @@ def imshow_zero_center(image, n):
plt.show()
def show_eigenvalues(A, n):
plt.loglog(tf.math.real(A), tf.math.imag(A), '.')
plt.plot(tf.math.real(A), tf.math.imag(A), '.r', alpha=0.3)
plt.xlabel("Realteil")
plt.ylabel("Imaginärteil")
plt.title("Eigenwerte der Hesse-Matrix für n = " + str(n))
plt.show()
def show_eigenvalues_semilog(A, n):
plt.semilogx(tf.math.real(A), tf.math.imag(A), '.r', alpha=0.3)
plt.xlabel("Realteil")
plt.ylabel("Imaginärteil")
plt.title("Eigenwerte der Hesse-Matrix für n = " + str(n))
......@@ -26,7 +33,7 @@ norms = norm(train_labels, ord=1, axis=0)
#show_fields(train_set, train_labels, 20)
# Eigene Aktivierungsfunktion: ReLu^3
size_hidden_layer = 50
size_hidden_layer = 100
from keras.layers import Activation
from keras import backend as K
......@@ -51,7 +58,7 @@ dataset = tf.data.Dataset.from_tensor_slices((train_set, train_labels))
# Klassifizierer trainieren
loss_fn = tf.keras.losses.CategoricalCrossentropy()
model.compile(optimizer='adam', loss=loss_fn)
model.fit(train_set, train_labels, batch_size=32, epochs=500, verbose=0)
model.fit(train_set, train_labels, batch_size=32, epochs=10000, verbose=0)
weights_and_bias = model.get_weights()
predictions = model.predict(train_set)
......@@ -99,5 +106,6 @@ h_mat = tf.concat([H_weights_1, H_bias_1, H_weights_2, H_bias_2], axis = 1)
imshow_zero_center(h_mat, n=size_hidden_layer)
# Eigenwerte berechnen und plotten
eig = tf.linalg.eig(h_mat)
show_eigenvalues(eig[0], size_hidden_layer)
\ No newline at end of file
eig = tf.linalg.eigh(h_mat)
show_eigenvalues(eig[0], size_hidden_layer)
show_eigenvalues_semilog(eig[0], size_hidden_layer)
\ 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