added reports and params

This commit is contained in:
2026-07-03 13:31:43 +02:00
parent 524991dc4e
commit 61da187012
33 changed files with 4872 additions and 755 deletions

View File

@@ -46,19 +46,23 @@ class Model(ABC):
file_path = Path(f"{mode}/{self.__class__.__name__.lower()}/time_metrics.txt")
Util._initialize_log_file(file_path)
#save_dir.mkdir(parents=True, exist_ok=True)
print(f"Starting training on {self.device}...")
start_time = time.time()
# training phase
self.model.train()
for epoch in range(epochs):
total_loss = 0.0
for inputs, labels in loader:
inputs, labels = inputs.to(self.device), labels.to(self.device)
# zero param gradients
optimizer.zero_grad()
# forward pass
outputs = self.model(inputs)
# comoutew loss
loss = criterion(outputs, labels)
# backward pass
loss.backward()
optimizer.step()
total_loss += loss.item()
@@ -66,7 +70,8 @@ class Model(ABC):
print(f"Epoch {epoch+1}/{epochs} | Loss: {total_loss / len(loader):.4f}")
end_time = time.time()
Util.log_metric(log_file=file_path, execution_time=(end_time - start_time))
execution_time = end_time - start_time
Util.log_metric(log_file=file_path, execution_time=execution_time)
if self.device.type == 'cuda': torch.cuda.synchronize()
print(f"Training completed in: {time.time() - start_time:.2f}s")