[FEATURE] Update pruning callback to re-add pruned prototypes
This commit is contained in:
@@ -30,7 +30,7 @@ if __name__ == "__main__":
|
||||
prototypes_per_class = num_clusters * 5
|
||||
hparams = dict(
|
||||
distribution=(num_classes, prototypes_per_class),
|
||||
lr=0.3,
|
||||
lr=0.1,
|
||||
)
|
||||
|
||||
# Initialize the model
|
||||
@@ -39,24 +39,21 @@ if __name__ == "__main__":
|
||||
prototype_initializer=pt.components.Ones(2, scale=3),
|
||||
)
|
||||
|
||||
# Summary
|
||||
print(model)
|
||||
|
||||
# Callbacks
|
||||
vis = pt.models.VisGLVQ2D(train_ds)
|
||||
pruning = pt.models.PruneLoserPrototypes(
|
||||
threshold=0.01, # prune prototype if it wins less than 1%
|
||||
idle_epochs=10, # pruning too early may cause problems
|
||||
prune_quota_per_epoch=5, # prune at most 5 prototypes per epoch
|
||||
frequency=2, # prune every second epoch
|
||||
idle_epochs=20, # pruning too early may cause problems
|
||||
prune_quota_per_epoch=2, # prune at most 2 prototypes per epoch
|
||||
frequency=1, # prune every epoch
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
es = pl.callbacks.EarlyStopping(
|
||||
monitor="train_loss",
|
||||
min_delta=0.001,
|
||||
patience=15,
|
||||
patience=20,
|
||||
mode="min",
|
||||
verbose=True,
|
||||
check_on_train_epoch_end=True,
|
||||
)
|
||||
|
||||
@@ -68,6 +65,7 @@ if __name__ == "__main__":
|
||||
pruning,
|
||||
es,
|
||||
],
|
||||
progress_bar_refresh_rate=0,
|
||||
terminate_on_nan=True,
|
||||
weights_summary=None,
|
||||
accelerator="ddp",
|
||||
|
Reference in New Issue
Block a user