Enhancements & Optimizations
• Implemented Exponential Moving Average (EMA) for threshold calibration. This replaces the previous global
accumulation method, resolving float32 precision loss limits and preventing early-epoch, untrained reconstruction
errors from inflating the final anomaly threshold.
• Re-engineered the base model extraction logic to fully support multi-output Functional architectures, preserving
the complete list of task outputs instead of inadvertently dropping all but the first.
Bug Fixes
• Added a custom test_step override to ImmuneModel. This natively fixes a structural mismatch crash (ValueError:
Too many leaves for PyTreeSpec) that occurred when calling Keras' model.evaluate() API.
• Fixed a multi-output training crash when compiling models with a dictionary of losses. ImmuneModel now
dynamically inspects the ground-truth targets and zips its predictions against base_model.output_names to construct
a matching dictionary for compute_loss.
• Fixed a serialization bug where calibration statistics and the anomaly threshold were excluded from weight saves.
Replaced tf.Variable instantiations with self.add_weight(), ensuring these parameters persist correctly when
calling model.save() and load_model().
• Fixed an internal Keras 3.x backend crash that occurred when inspecting the output tensors of an explicitly
instantiated tf.keras.Sequential model.