reports from optimised linear filtration
This commit is contained in:
@@ -43,12 +43,12 @@ class Model(ABC):
|
||||
|
||||
scheduler = CosineAnnealingLR(optimizer, T_max=epochs, eta_min=1e-6)
|
||||
# to save reports
|
||||
file_path = Path(f"{mode}/{self.__class__.__name__.lower()}/time_metrics.txt")
|
||||
Util._initialize_log_file(file_path)
|
||||
# file_path = Path(f"{mode}/{self.__class__.__name__.lower()}/time_metrics.txt")
|
||||
# Util._initialize_log_file(file_path)
|
||||
|
||||
|
||||
print(f"Starting training on {self.device}...")
|
||||
start_time = time.time()
|
||||
# start_time = time.time()
|
||||
# training phase
|
||||
self.model.train()
|
||||
|
||||
@@ -69,11 +69,11 @@ class Model(ABC):
|
||||
scheduler.step()
|
||||
|
||||
print(f"Epoch {epoch+1}/{epochs} | Loss: {total_loss / len(loader):.4f}")
|
||||
end_time = time.time()
|
||||
execution_time = end_time - start_time
|
||||
Util.log_metric(log_file=file_path, execution_time=execution_time)
|
||||
#end_time = time.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")
|
||||
print(f"Training complete.")
|
||||
|
||||
|
||||
def save(self, filename=None):
|
||||
@@ -108,7 +108,7 @@ class Model(ABC):
|
||||
self.model.to(self.device)
|
||||
print(f'Model loaded from {file_path}')
|
||||
|
||||
|
||||
'''
|
||||
def unlearn(self, strategy: 'Strategy', forget_loader, retain_loader):
|
||||
""" Executes a targeted unlearning strategy and profiles efficiency """
|
||||
print(f"Executing: {strategy.__class__.__name__}...")
|
||||
@@ -122,6 +122,7 @@ class Model(ABC):
|
||||
print(f"{strategy.__class__.__name__} completed in {elapsed_time:.4f} seconds.")
|
||||
|
||||
return elapsed_time
|
||||
'''
|
||||
|
||||
def evaluate(self, loader, mode="eval"):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user