Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

44 lignes
2.0KB

  1. import tkinter as tk
  2. from neural_net.epoch import Epoch
  3. class EpochInformation(tk.LabelFrame):
  4. def __init__(self, parent, epoch: Epoch):
  5. super().__init__(parent, text="Last epoch info")
  6. self.epoch = epoch
  7. self.lbl_epoch_training_time = None
  8. self.lbl_last_loss = None
  9. self.create_ui()
  10. def create_ui(self):
  11. row = 0
  12. tk.Label(self, text="Duration:", anchor=tk.W).grid(column=0, row=row,
  13. sticky=tk.E,
  14. padx=(10, 20), pady=5)
  15. self.lbl_epoch_training_time = tk.Label(self, text=f"{self.epoch.duration:.2f}sec")
  16. self.lbl_epoch_training_time.grid(column=1, row=row, sticky=tk.E, padx=10, pady=5)
  17. row += 1
  18. tk.Label(self, text="Loss value:", anchor=tk.W).grid(column=0, row=row,
  19. sticky=tk.E, padx=(10, 20),
  20. pady=5)
  21. self.lbl_last_loss = tk.Label(self, text=f"{self.epoch.loss:.4f}")
  22. self.lbl_last_loss.grid(column=1, row=row, sticky=tk.E, padx=10, pady=5)
  23. row += 1
  24. tk.Label(self, text="Learning rate:", anchor=tk.W).grid(column=0, row=row,
  25. sticky=tk.E, padx=(10, 20),
  26. pady=5)
  27. self.lbl_learning_rate = tk.Label(self, text=f"{self.epoch.learning_rate:.4f}")
  28. self.lbl_learning_rate.grid(column=1, row=row, sticky=tk.E, padx=10, pady=5)
  29. def update(self):
  30. print(f"Updating training data for epoch {self.epoch}")
  31. self.lbl_epoch_training_time.config(text=f"{self.epoch.duration:.2f}sec")
  32. self.lbl_last_loss.config(text=f"{self.epoch.loss:.4f}")
  33. self.lbl_learning_rate.config(text=f"{self.epoch.learning_rate:.4f}")
  34. def set_epoch(self, epoch: Epoch):
  35. self.epoch = epoch
  36. self.update()