Update app.py
Browse files
app.py
CHANGED
|
@@ -139,14 +139,16 @@ def run_unlearning(index_to_unlearn, learning_rate):
|
|
| 139 |
|
| 140 |
# Prediction before unlearning
|
| 141 |
probs_before, pred_before = predict(original_model, image_tensor)
|
| 142 |
-
|
|
|
|
| 143 |
|
| 144 |
# Perform the unlearning process on the duplicated model
|
| 145 |
unlearn(unlearned_model, image_tensor, label_idx, learning_rate)
|
| 146 |
|
| 147 |
# Prediction after unlearning
|
| 148 |
probs_after, pred_after = predict(unlearned_model, image_tensor)
|
| 149 |
-
|
|
|
|
| 150 |
|
| 151 |
print("Post-unlearning probabilities:", probs_after)
|
| 152 |
|
|
@@ -157,13 +159,17 @@ def run_unlearning(index_to_unlearn, learning_rate):
|
|
| 157 |
result = f"""
|
| 158 |
π Index Unlearned: {index_to_unlearn}
|
| 159 |
ποΈ Actual Label: {label_name} (Index: {label_idx})
|
|
|
|
| 160 |
π BEFORE Unlearning:
|
| 161 |
-
-
|
| 162 |
-
-
|
|
|
|
| 163 |
π§½ AFTER Unlearning:
|
| 164 |
-
-
|
| 165 |
-
-
|
| 166 |
-
|
|
|
|
|
|
|
| 167 |
π§ͺ Test Set Performance:
|
| 168 |
- Original Model: {orig_acc:.2f}% accuracy, Loss: {orig_loss:.4f}
|
| 169 |
- Unlearned Model: {unlearn_acc:.2f}% accuracy, Loss: {unlearn_loss:.4f}
|
|
|
|
| 139 |
|
| 140 |
# Prediction before unlearning
|
| 141 |
probs_before, pred_before = predict(original_model, image_tensor)
|
| 142 |
+
conf_actual_before = probs_before[label_idx].item()
|
| 143 |
+
conf_pred_before = probs_before[pred_before].item()
|
| 144 |
|
| 145 |
# Perform the unlearning process on the duplicated model
|
| 146 |
unlearn(unlearned_model, image_tensor, label_idx, learning_rate)
|
| 147 |
|
| 148 |
# Prediction after unlearning
|
| 149 |
probs_after, pred_after = predict(unlearned_model, image_tensor)
|
| 150 |
+
conf_actual_after = probs_after[label_idx].item()
|
| 151 |
+
conf_pred_after = probs_after[pred_after].item()
|
| 152 |
|
| 153 |
print("Post-unlearning probabilities:", probs_after)
|
| 154 |
|
|
|
|
| 159 |
result = f"""
|
| 160 |
π Index Unlearned: {index_to_unlearn}
|
| 161 |
ποΈ Actual Label: {label_name} (Index: {label_idx})
|
| 162 |
+
|
| 163 |
π BEFORE Unlearning:
|
| 164 |
+
- Predicted Class: {cifar10_classes[pred_before]} with confidence: {conf_pred_before:.10f}
|
| 165 |
+
- Actual Class: {label_name} with confidence: {conf_actual_before:.10f}
|
| 166 |
+
|
| 167 |
π§½ AFTER Unlearning:
|
| 168 |
+
- Predicted Class: {cifar10_classes[pred_after]} with confidence: {conf_pred_after:.10f}
|
| 169 |
+
- Actual Class: {label_name} with confidence: {conf_actual_after:.10f}
|
| 170 |
+
|
| 171 |
+
π Confidence Drop (Actual Class): {conf_actual_before - conf_actual_after:.6f}
|
| 172 |
+
|
| 173 |
π§ͺ Test Set Performance:
|
| 174 |
- Original Model: {orig_acc:.2f}% accuracy, Loss: {orig_loss:.4f}
|
| 175 |
- Unlearned Model: {unlearn_acc:.2f}% accuracy, Loss: {unlearn_loss:.4f}
|