forked from endrikacupaj/CARTON
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: improve logging and clean up console output
- Loading branch information
Showing
4 changed files
with
118 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import pathlib | ||
import re | ||
from matplotlib import pyplot as plt | ||
|
||
|
||
# Function to extract epoch and validation loss from file names | ||
def extract_data(file_names): | ||
epochs = [] | ||
losses = [] | ||
for file_name in file_names: | ||
match = re.search(r"_e(\d+)_v([\d.]+)_", file_name) | ||
if match: | ||
epoch, loss = match.groups() | ||
epochs.append(int(epoch)) | ||
losses.append(float(loss)) | ||
return epochs, losses | ||
|
||
|
||
def plot(results: dict): | ||
plt.figure(figsize=(10, 6)) | ||
for name, result in results.items(): | ||
epochs = result[0] | ||
losses = result[1] | ||
plt.plot(epochs, losses, label=name) | ||
|
||
plt.xlabel('Epoch') | ||
plt.ylabel('Validation Loss') | ||
plt.title('Validation Loss Across Epochs') | ||
plt.legend() | ||
plt.grid(True) | ||
plt.show() | ||
|
||
|
||
if __name__ == "__main__": | ||
folders = {"csqa": "pth/to/csqa/results/folder", | ||
"merged": "pth/to/merged/results/folder"} | ||
|
||
results = {} | ||
for name, fldr in folders.items(): | ||
files = pathlib.Path(fldr).glob("*.pth.tar") | ||
|
||
# Extracting data | ||
epochs, losses = extract_data(files) | ||
|
||
results[name] = (epochs, losses) | ||
|
||
print(results) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters