Revision 15b6abe1dc75373a5e9bb944d331f209a67a88d2 authored by Martin Skrodzki on 18 December 2023, 16:03:43 UTC, committed by Martin Skrodzki on 18 December 2023, 16:03:43 UTC
1 parent 073e059
util.py
import os
import numpy as np
def find_last_embedding(log_path):
""" Give a path with logging results, finds the last embedding saved there.
"""
for subdir, dirs, files in reversed(list(os.walk(log_path))):
files = [f for f in files if not f[0] == '.']
dirs[:] = [d for d in dirs if not d[0] == '.']
for fi, file in enumerate(reversed(sorted(files, key=lambda x: int(x.split(", ")[0])))):
root, ext = os.path.splitext(file)
if ext == ".csv":
total_file = subdir.replace("\\", "/") + "/" + file
return np.genfromtxt(total_file, delimiter=',')
def find_ith_embedding(log_path, i):
""" Give a path with logging results, finds the i-th embedding saved there.
"""
j = 0
for subdir, dirs, files in list(os.walk(log_path)):
files = [f for f in files if not f[0] == '.']
dirs[:] = [d for d in dirs if not d[0] == '.']
for fi, file in enumerate(sorted(files, key=lambda x: int(x.split(", ")[0]))):
root, ext = os.path.splitext(file)
if ext == ".csv":
j += 1
if j >= i:
total_file = subdir.replace("\\", "/") + "/" + file
return np.genfromtxt(total_file, delimiter=',')

Computing file changes ...