cv-epoch-prediction-averaging
SkillDev toolsCollect test predictions each epoch via callback and combine with exponentially increasing weights favoring later epochs
Available today. Use it from your connected AI after setup.
No other account needed.
Connect ahel once, and every AI you use reads what you have installed.
Then ask your AI: use the cv-epoch-prediction-averaging skill
What this skill tells your AI
The instructions your AI receives, as published by wenmin-wu/ds-skills in skills/cv/epoch-prediction-averaging/SKILL.md and read by ahel’s review.
Overview
Instead of using only the final-epoch model for inference, collect test predictions at the end of every epoch and combine them with exponentially increasing weights. Later epochs get more weight because the model improves over training. This acts as a free ensemble across training checkpoints without saving multiple model files.
Quick Start
import numpy as np
from keras.callbacks import Callback
class PredictionCheckpoint(Callback):
def __init__(self, test_generator, test_len):
self.test_generator = test_generator
self.test_len = test_len
self.test_predictions = []
def on_epoch_end(self, epoch, logs=None):
preds = self.model.predict(self.test_generator)[:self.test_len]
self.test_predictions.append(preds)
# After training
weights = [2 ** i for i in range(len(cb.test_predictions))] # 1, 2, 4, 8, ...
final_preds = np.average(cb.test_predictions, axis=0, weights=weights)
Workflow
- Create a callback that runs
model.predicton test data at each epoch end - Store predictions in a list indexed by epoch
- After training completes, define exponential weights:
[2^0, 2^1, ..., 2^(n-1)] - Compute weighted average across all epoch predictions
- Use the averaged predictions for submission
Key Decisions
- Weight scheme: Exponential (1, 2, 4, 8...) emphasizes later epochs. Linear (1, 2, 3...) is gentler. Skip first few epochs if early predictions are noisy.
- Memory: Storing predictions for all epochs uses
n_epochs * n_samples * n_classesmemory. For large test sets, keep only the last K epochs. - vs. checkpoint ensemble: This avoids saving/loading multiple model files. Trade-off: requires test inference at every epoch during training.
References
Signals
- GitHub stars
- 60
- Forks
- 4
- Last commit
- Apr 2026
Advanced
- Catalog kind
- skill
- Gateway key
cv-epoch-prediction-averaging- Source
- github.com/wenmin-wu/ds-skills