started unlearning setup

This commit is contained in:
2026-05-31 22:22:38 +02:00
parent 770b7be936
commit e90480adbe
10 changed files with 229 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import time
import numpy as np
from sklearn.metrics import classification_report
from pathlib import Path
from unlearning.Strategy import Strategy
class Model(ABC):
def __init__(self, device, size):
@@ -92,6 +93,21 @@ 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__}...")
start_time = time.time()
# Delegate the actual algorithmic weight/logit manipulation to the strategy
strategy.apply(self.network, forget_loader, retain_loader)
elapsed_time = time.time() - start_time
print(f"{strategy.__class__.__name__} completed in {elapsed_time:.4f} seconds.")
return elapsed_time
# Using the factory patern here