Checkpoint
This commit is contained in:
parent
8311eabd4d
commit
926cde17d3
3 changed files with 24 additions and 13 deletions
6
main.py
6
main.py
|
|
@ -29,7 +29,11 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
case 'compress':
|
case 'compress':
|
||||||
compress(args.input_file)
|
compress(device=device,
|
||||||
|
model_path=args.model_load_path,
|
||||||
|
input_file=args.input_file,
|
||||||
|
output_file=args.output_file
|
||||||
|
)
|
||||||
|
|
||||||
case _:
|
case _:
|
||||||
raise NotImplementedError(f"Mode {args.mode} is not implemented yet")
|
raise NotImplementedError(f"Mode {args.mode} is not implemented yet")
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ def parse_arguments():
|
||||||
help="Which model to use")
|
help="Which model to use")
|
||||||
modelparser.add_argument("--model-load-path", type=str, required=False,
|
modelparser.add_argument("--model-load-path", type=str, required=False,
|
||||||
help="Filepath to the model to load")
|
help="Filepath to the model to load")
|
||||||
modelparser.add_argument("--model-save-path", type=str, required=True,
|
modelparser.add_argument("--model-save-path", type=str, required=False,
|
||||||
help="Filepath to the model to save")
|
help="Filepath to the model to save")
|
||||||
|
|
||||||
fileparser = ArgumentParser(add_help=False)
|
fileparser = ArgumentParser(add_help=False)
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
from os import path
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from torch.utils.data import TensorDataset
|
from torch.utils.data import TensorDataset
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
@ -14,7 +16,7 @@ def print_distribution(from_to: tuple[int, int], probabilities: list[float]):
|
||||||
plt.hist(range(from_to[0], from_to[1]), weights=probabilities)
|
plt.hist(range(from_to[0], from_to[1]), weights=probabilities)
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
def print_losses(train_losses: list[float], validation_losses: list[float], show=False):
|
def print_losses(train_losses: list[float], validation_losses: list[float], filename: str | None = None, show=False):
|
||||||
plt.plot(train_losses, label="Training loss")
|
plt.plot(train_losses, label="Training loss")
|
||||||
plt.plot(validation_losses, label="Validation loss")
|
plt.plot(validation_losses, label="Validation loss")
|
||||||
plt.xlabel("Epoch")
|
plt.xlabel("Epoch")
|
||||||
|
|
@ -23,7 +25,12 @@ def print_losses(train_losses: list[float], validation_losses: list[float], show
|
||||||
|
|
||||||
if show:
|
if show:
|
||||||
plt.show()
|
plt.show()
|
||||||
plt.savefig("losses.png")
|
|
||||||
|
if filename is None:
|
||||||
|
filename = path.join("results", "losses.png")
|
||||||
|
|
||||||
|
print(f"Saving losses to {filename}...")
|
||||||
|
plt.savefig(filename)
|
||||||
|
|
||||||
|
|
||||||
def load_data(path: str) -> bytes:
|
def load_data(path: str) -> bytes:
|
||||||
|
|
|
||||||
Reference in a new issue