Add stacked layers, dropout, benchmark, and contributor docs - #4
Merged
Conversation
Stacking and regularisation: - num_layers on QLSTM/LQLSTM stacks recurrent layers; each layer reads the hidden-state sequence of the layer below, and h_n/c_n are shaped (num_layers, batch, hidden_size), matching torch.nn.LSTM. - dropout applies between stacked layers (every layer except the last). - The single-layer path and the layer.cell attribute are unchanged, so existing code keeps working. Tests: - Add coverage for stacked shapes, gradient flow to every layer, stacked initial state, the wrong-layer-count error, eval-time dropout determinism, the cell property, and constructor validation. Full suite: 18 passed. Examples: - examples/benchmark_vs_classical.py runs a fair side-by-side against torch.nn.LSTM on the same task and reports parameter counts and losses. Docs and metadata: - README documents stacking and the benchmark; CHANGELOG records the changes. - Add community health files (CONTRIBUTING, issue and pull-request templates). - Add the Python 3.13 packaging classifier, which CI already tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Summary
Extends the
qlstmlibrary towardtorch.nn.LSTMparity and hardens the repofor contributors, without breaking the existing single-layer API.
Changes
Stacking and regularisation
num_layersonQLSTM/LQLSTMstacks recurrent layers. Each layer reads thehidden-state sequence of the layer below;
outputis the top layer's sequenceand
h_n/c_nare shaped(num_layers, batch, hidden_size), as intorch.nn.LSTM.dropoutapplies to the output of every layer except the last.layer.cellattribute are unchanged, soexisting code keeps working.
Tests
state, the wrong-layer-count error, eval-time dropout determinism, the
cellproperty, and constructor validation. Full suite: 18 passed.
Examples
examples/benchmark_vs_classical.pyruns a fair side-by-side againsttorch.nn.LSTMon the same running-sum task and prints parameter counts andtrain/validation loss. It is a reproducible comparison, not a performance
claim.
Docs and metadata
changes.
CONTRIBUTING.md, issue templates, pull-requesttemplate.
Test plan
pytest -qgreen locally (18 passed).