Repository navigation
Phase 4: RNN warmup without init model, trajectory loss, step model export - #74
Merged
Merged
Conversation
…d export the step model
- RNNModel: no separate initialization model. A sequence of warmup_width + label_width
steps starts from zero states, the warmup is not part of the loss (as in AgentLib-MPC).
- Change(T) outputs are accumulated to the trajectory of T from the measured start value,
the loss runs on the trajectory (loss_on='trajectory' | 'outputs') with optional step
weights. If T is also an input, it is fed back in training and evaluation (closed loop).
- The saved .keras file is the step model [sequence, *states] -> [prediction, *states];
verified against the MPC of AgentLib-MPC branch 143 (RNN, GRU, LSTM, with and without
feedback) and covered by a contract test that runs once AgentLib-MPC supports RNNs.
- TrainingDataMultiStep: sequences as views on the time series, eval_horizon longer than
the training horizon, HorizonMetrics per output.
- Removed: init_layer, init_features, warmup_columns_*, closed_loop.py and the multi step
evaluation of single step models on PreprocessingMultiStep (use eval_horizon of
PreprocessingSingleStep; feature selection migrated).
- Fixes: RNN summary / verbosity / batch size, Rescaling with tensors, init_layer
validator ('is not'), seed set in RNNModel.__init__, PINN pipelines returned None.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phase 4 of the 1.0.0 refactoring (Phases 1–3 are merged in
refactoring_v1.0.0).RNN without an initialization model
warmup_width + label_widthsteps starts from zero states. The warmup steps are not part of the loss. AgentLib-MPC (branch 143) warms the model up the same way.init_layer,init_featuresandwarmup_columns_*are removed.px.Change('T')the model predicts the trajectory of T, i.e. the measured start value plus the accumulated changes. The model is trained on this trajectory (loss_on='trajectory', alternatively'outputs'), optionally with step weights (first_step_weight,step_weights).Tis also an input, the prediction is fed back during training and evaluation, as in the MPC.eval_horizoncan be longer thanlabel_widthand shows the stability beyond the training horizon.td.horizon_metricsholds RMSE, MAE and bias per step,by_featurethe same per output.Export for AgentLib-MPC
{name}.kerasnow contains the step modelrnn_step:[sequence, *states] -> [prediction, *states]. Its input layers are named*_input, because AgentLib-MPC recognizes inputs by that name.Verified with a worktree of
143-feature-multistep-model-support:save_for_agentliband translated withphysXAI_2_agentlib_jsongive exactly the keras trajectory in the MPC of branch 143 (solve_mpcfrom its tests). That holds for RNN, GRU and LSTM, each with and without feeding backT. The maximum deviation is about 1e-6.test_recurrent_ml_model.py,test_physXAI_plugin): 28 passed.unittests/contract/test_agentlib_rnn.py. It is skipped with AgentLib-MPC main and runs as soon as the installed version supports RNNs.Branch 143 needs no change. It finds the step model at the top level by its signature.
Further changes
PreprocessingMultiStepdata are removed (evaluate_multi), along withclosed_loop.py. The replacement isPreprocessingSingleStep(eval_horizon=...)from Phase 3.TAir_evaluateMultiStep.py/TAir_FeatureSelection.pywere migrated to this. Their output wasChange(T_zone), which has no base column; they now useChange(reaTZon_y), so that the multi step evaluation runs.RNNModel. InPreprocessingMultiStepit is ignored with a warning.Rescalinglayer held tensors (Support Phyton 3.9 - 3.11 #30).init_layervalidator compared withis not(Update Citation #27).RNNModel.__init__(Updated #25).PINNModel.pipeline/online_pipelinereturnedNone(Added new csv formats, added time sampling, added better nan handling #23).fitno longer passesshuffle=Trueon top of the already shuffledtf.datapipelines, which removes the keras warning.Tests
test_physXAI_plugintests andsimple_mpc_nn_physXAI.run_example(testing=True)pass.TAir_rnn.pywith full epochs: 16 s, early stopping after 30 epochs. The BOPTEST data cover only 14 days, so with 6 h warmup and 24 h horizon only one window each fits into val and test. The horizon errors are therefore not meaningful.🤖 Generated with Claude Code