started unlearning setup
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user