reports from optimised linear filtration
This commit is contained in:
21
Tune_new.py
21
Tune_new.py
@@ -133,7 +133,7 @@ def run_finetuning_or_baseline_eval(env_dict, run_training=False, lr_rate=0.0001
|
||||
# Evaluate original base checkpoint performance
|
||||
current_mode = "Finetuned"
|
||||
|
||||
# Check if weights exist or model was trained before evaluating
|
||||
# evaluate finetuned model
|
||||
try:
|
||||
accuracy, report_dict = model.evaluate(loader=test_loader, mode=current_mode)
|
||||
Util._log_to_csv(
|
||||
@@ -178,6 +178,8 @@ def run_unlearning_and_strategy_eval(env_dict, forget_class_idx, strategy, evalu
|
||||
print("fine tunned model loaded into evaluation sandbox")
|
||||
|
||||
# Execute strategic parameter unlearning step
|
||||
# we are using only training data to unlearn.
|
||||
# Test data is never touched here.
|
||||
unlearned = strategy.apply(reloaded.model, train_data)
|
||||
strategy_in_use = strategy.__class__.__name__
|
||||
|
||||
@@ -200,7 +202,7 @@ def run_unlearning_and_strategy_eval(env_dict, forget_class_idx, strategy, evalu
|
||||
print(domain["label"])
|
||||
accuracy, report_dict = reloaded.evaluate(loader=domain["loader"], mode=domain["mode"])
|
||||
Util._log_to_csv(
|
||||
arch=ARCH.name,#reloaded.__class__.__name__,
|
||||
arch=ARCH.name,
|
||||
mode=domain["mode"],
|
||||
accuracy=accuracy,
|
||||
report_dict=report_dict,
|
||||
@@ -211,7 +213,7 @@ def run_unlearning_and_strategy_eval(env_dict, forget_class_idx, strategy, evalu
|
||||
# entry
|
||||
if __name__ == "__main__":
|
||||
|
||||
outer_loop = 10
|
||||
outer_loop = 11
|
||||
inner_loop = CLASS_SIZE
|
||||
|
||||
for k in range(outer_loop):
|
||||
@@ -221,15 +223,17 @@ if __name__ == "__main__":
|
||||
runtime_environment = prepare_data_and_model_environment()
|
||||
|
||||
# Baseline Evaluation
|
||||
# switch finetuning for tests on strategies only,
|
||||
# to avoid finetunning every time we test a strategy
|
||||
finetuning = True
|
||||
# switch finetuning for tests on strategies only
|
||||
run_finetuning_or_baseline_eval(runtime_environment, run_training = finetuning)
|
||||
# scale 16400.0 for ResNet
|
||||
scale = 20200
|
||||
scale = 20300
|
||||
# batch 8 for resNet,
|
||||
unlearning_batches = 16
|
||||
# regularis
|
||||
# strategies
|
||||
# implementation of Certified Removal for DNNs
|
||||
certified_unlearning = CertifiedUnlearning(
|
||||
target_class_index=0, #arch ResNet18 GoogLeNet Inception
|
||||
l2_reg=0.000002 , # 0.000002 0.00001 0.0
|
||||
@@ -241,12 +245,13 @@ if __name__ == "__main__":
|
||||
unlearn_bs=unlearning_batches # 8 32 8
|
||||
)
|
||||
|
||||
# works perfectly
|
||||
# Normalisation Filtration
|
||||
linear_filtration = LinearFiltration(
|
||||
|
||||
target_class_index=0
|
||||
target_class_index=0,
|
||||
num_classes=CLASS_SIZE
|
||||
)
|
||||
|
||||
# WF-Net
|
||||
weight_filtration = WeightFiltration(
|
||||
target_class_index=0, #arch ResNet18 GoogLeNet/Inception
|
||||
epochs=6, #
|
||||
|
||||
Reference in New Issue
Block a user