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

@@ -40,10 +40,11 @@ def test_transform(res):
)
])
# Load data with 'identity' as target and transform it
# Load data
def get_set(set_name:Set_Name):
return fetch_celeb_a() if set_name == Set_Name.CELEBA else fetch_casia_faces()
# celebA
def fetch_celeb_a():
return datasets.CelebA(
root='./data',
@@ -53,6 +54,7 @@ def fetch_celeb_a():
transform=None
)
# CASIA-WebFaces
def fetch_casia_faces():
# location of the data (path relative to project root)
final_path = os.path.abspath("./data/casia-set")
@@ -191,12 +193,12 @@ def vertical_split(dataset, batch_size,num_classes):
50% of each class goes to the Retain Set, 50% goes to the Forget Set.
"""
# 1. Group dataset indices by their respective ground-truth classes
# Dataset indices by their respective ground-truth classes
class_to_indices = {c: [] for c in range(num_classes)}
print(" [Vertical Split] Tracking class indices across the combined dataset...")
for idx in range(len(dataset)):
# Extract the label cleanly from the underlying dataset structure
# Extract labels
_, label = dataset[idx]
if label in class_to_indices:
class_to_indices[label].append(idx)
@@ -204,14 +206,14 @@ def vertical_split(dataset, batch_size,num_classes):
retain_indices = []
forget_indices = []
# 2. Slice each class identity vertically (exactly 50/50)
# Slice each class identity vertically (exactly 50/50)
for c, indices in class_to_indices.items():
if len(indices) < 2:
print(f" Warning: Class {c} has fewer than 2 samples. Cannot split vertically.")
retain_indices.extend(indices)
continue
# Deterministic shuffle per class to ensure honest distribution before splitting
# Suffle to ensure honest distribution before splitting
np.random.shuffle(indices)
mid = len(indices) // 2
@@ -220,11 +222,10 @@ def vertical_split(dataset, batch_size,num_classes):
print(f" Vertical split complete: Retain Index Size = {len(retain_indices)} | Forget Index Size = {len(forget_indices)}")
# 3. Construct lightweight PyTorch Subsets using our sliced index maps
# Subsets using our sliced index maps
retain_subset = Subset(dataset, retain_indices)
forget_subset = Subset(dataset, forget_indices)
# 4. Return pristine, shuffled DataLoaders mirroring your environment's batch specifications
retain_loader = DataLoader(retain_subset, batch_size=batch_size, shuffle=True)
forget_loader = DataLoader(forget_subset, batch_size=batch_size, shuffle=True)