MAEEvaluator#
- class MAEEvaluator(every_n_steps: int = 0, max_batches: int | None = None, log_pointclouds: bool = True)[source]#
Bases:
HookBaseValidation hook for masked-autoencoder (MAE) pretraining.
Runs the MAE model over
trainer.val_loaderon rank 0 only (other ranks synchronize), averaging the reconstruction losses (total, coordinate, feature) and the actual mask ratio over the valid batches (batches whoseloss == 0from empty masks are skipped). On the first batch it can log ground-truth vs reconstructed point-cloud visualizations to Weights & Biases. It publishes the NEGATIVE average validation loss as the checkpoint-selection metric (current_metric_value=-avg_loss,current_metric_name=neg_val_loss) so that higher is better. Uses AMP autocast whencfg.enable_ampis set. Runs after every step whenevery_n_steps > 0(when(global_iter + 1) % every_n_steps == 0), otherwise after each epoch; only whencfg.evaluateis true andval_loaderis notNone. Registered asMAEEvaluator(use astypein ahooks=[...]entry).- Parameters:
every_n_steps (int) – Step cadence;
0evaluates once per epoch. Defaults to0.max_batches (int | None) – Cap on validation batches per eval for speed;
Noneuses all batches. Defaults toNone.log_pointclouds (bool) – Log first-batch GT/reconstruction point clouds to wandb. Defaults to
True.
Note
The selection metric is NEGATIVE validation loss (
neg_val_loss); higher (less negative) is better. Evaluation runs on rank 0 only.Example
Add to
cfg.hooksfor MAE pretraining; everyevery_n_stepsit runs reconstruction validation on rank 0:hooks = [dict(type="MAEEvaluator", every_n_steps=1000, max_batches=50)] # → every 1000 steps logs val/loss, val/coord_loss, val/feat_loss, # val/mask_ratio to the writer (and first-batch GT/recon point clouds # to wandb), then sets the checkpoint-selection metric to neg_val_loss # (= -avg loss, so higher is better)