Dateien nach „/“ hochladen

This commit is contained in:
David Rotermund 2024-12-10 12:48:21 +01:00
parent f129b77363
commit d93cb0a9b3
2 changed files with 46 additions and 0 deletions

31
convert_log_to_numpy.py Normal file
View file

@ -0,0 +1,31 @@
import os
import glob
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
from tensorboard.backend.event_processing import event_accumulator # type: ignore
import numpy as np
def get_data(path: str = "log_cnn"):
acc = event_accumulator.EventAccumulator(path)
acc.Reload()
which_scalar = "Test Number Correct"
te = acc.Scalars(which_scalar)
np_temp = np.zeros((len(te), 2))
for id in range(0, len(te)):
np_temp[id, 0] = te[id].step
np_temp[id, 1] = te[id].value
print(np_temp[:, 1] / 100)
np_temp = np.nan_to_num(np_temp)
return np_temp
for path in glob.glob("log_*"):
print(path)
data = get_data(path)
np.save("data_" + path + ".npy", data)

15
plot.py Normal file
View file

@ -0,0 +1,15 @@
import numpy as np
import matplotlib.pyplot as plt
data = np.load("data_log.npy")
plt.loglog(
data[:, 0],
100.0 * (1.0 - data[:, 1] / 10000.0),
"k",
)
plt.legend()
plt.xlabel("Epoch")
plt.ylabel("Error [%]")
plt.title("CIFAR10")
plt.show()