facebook's implementation
This commit is contained in:
@@ -5,9 +5,8 @@ from .Strategy import Strategy
|
||||
from torch.utils.data import DataLoader
|
||||
|
||||
class LinearFiltration(Strategy):
|
||||
def __init__(self, target_class_idx: int):
|
||||
super().__init__()
|
||||
self.target_class_idx = target_class_idx
|
||||
def __init__(self,target_class_index):
|
||||
super().__init__(target_class_index = target_class_index)
|
||||
|
||||
def _run(self, model: nn.Module, forget_loader: DataLoader, retain_loader: DataLoader) -> nn.Module:
|
||||
model.eval()
|
||||
@@ -18,7 +17,7 @@ class LinearFiltration(Strategy):
|
||||
W = model.fc.weight.data.clone()
|
||||
num_classes = W.shape[0]
|
||||
|
||||
A = self._calculate_filtration_matrix(num_classes, self.target_class_idx, W.device)
|
||||
A = self._calculate_filtration_matrix(num_classes, self.target_class_index, W.device)
|
||||
sanitized_W = torch.mm(A, W)
|
||||
model.fc.weight.copy_(sanitized_W)
|
||||
# Filter the bias (if the layer uses one)
|
||||
|
||||
Reference in New Issue
Block a user