Keras example saves .keras ObjectStore keys but searches for keys without the extension

Open Beginner friendly
#10,216 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start with Algorithm.Python/KerasNeuralNetworkAlgorithm.py: initialize (around lines 34-40) compares ObjectStore keys to f'{symbol}_model', while on_end_of_algorithm (around lines 58-64) saves f'{symbol}_model.keras'. Pick one key convention and make both paths use it. Done when a model saved in one run is found and loaded by keras.models.load_model on restart, and a round-trip test covers that contract.

Written by the indexing model from the issue text.

Description

priority:p2
Problem

KerasNeuralNetworkAlgorithm saves models under keys that its initialization never accepts:

Consequently, restarting with models saved by the example skips keras.models.load_model for every saved model. The extension was added to the saving path in #8658, but not to the loading comparison.

Reproduction and evidence
  1. Run the example until it trains and saves a model.
  2. Restart with the same ObjectStore.
  3. The saved SPY_model.keras key does not equal the expected SPY_model, so initialization continues without restoring it.

Evaluating the actual key-assignment AST expressions from the current source with symbol='SPY' produces:

initialize: SPY_model
on_end_of_algorithm: SPY_model.keras

This verifies the key mismatch independently of TensorFlow execution; a complete training/restart run was not performed.

Required result

A model saved by the example must be discovered and restored on the next run, using a compatible Keras filename and preserving its trained weights. Add a round-trip regression test for the save/load key contract.

Dominant language
C#
Stars
22.6k
Forks
5.4k
Avg merge
11h 39m
Merged PRs (30d)
104

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from QuantConnect/Lean

All issues in QuantConnect/Lean

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.