-
Notifications
You must be signed in to change notification settings - Fork 5
New package to extract latents from high-dimensional data using LDS and TorchSharp #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
6b0e89b to
93a8db0
Compare
|
Leaving here a summary of what we discussed earlier about deprecating the
The one consideration we discussed was whether to "nest" namespaces, e.g. we could use the name |
998bf00 to
c4e3bab
Compare
|
Updating the namespace of the existing |
c4e3bab to
274e6b4
Compare
fc8b8c0 to
1daacad
Compare
glopesdev
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, left only a few minor comments to review.
docs/README.md
Outdated
| > [!NOTE] | ||
| > Bonsai.ML packages can be installed through Bonsai's integrated package manager and are generally ready for immediate use. However, some packages may require additional installation steps. Refer to the specific package section for detailed installation guides and documentation. | ||
| ### Bonsai.ML.Torch.LDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to match package and project name.
| @@ -0,0 +1,7 @@ | |||
| # Bonsai.ML.Torch.LDS - Overview | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
|
||
| ## Installation Guide | ||
|
|
||
| Install the `Bonsai.ML.Torch.LDS` package from the Bonsai package manager. You will also need to follow the [instructions for setting up the Bonsai.ML.Torch package](../Torch/torch-overview.md) for running on the CPU or GPU. No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename the package name as above.
docs/articles/toc.yml
Outdated
| - name: Overview | ||
| href: Torch/torch-overview.md | ||
| href: Torch/torch-overview.md | ||
| - name: Torch.LDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above to align the naming.
|
|
||
| using static TorchSharp.torch; | ||
|
|
||
| [assembly: TypeVisualizer(typeof(Bonsai.ML.Lds.Torch.Design.ExpectationMaximizationVisualizer), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a thought but given the current decision to lean more on acronyms, this could also be called EMVisualizer.
However, we do have a class already that is named ExpectationMaximization and we probably don't want to contract that to EM, and I do also like the verbose name as it is, so I am torn and more than happy to go either way and leave it as-is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we keep the full name for now and we can revisit down the line if we want to change it
src/Bonsai.ML.Lds.Torch/ILdsState.cs
Outdated
| /// <summary> | ||
| /// Represents the state of a linear gaussian dynamical system. | ||
| /// </summary> | ||
| public interface ILdsState |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have been wondering whether we should expand Lds inside class names (i.e. leave only the package name with the acronym, but expand inner names).
Just leaving this comment here as the name of this interface was quite opaque to decipher, versus the alternative ILinearDynamicalSystemState.
| /// </summary> | ||
| /// <param name="smoothedMean"></param> | ||
| /// <param name="smoothedCovariance"></param> | ||
| public struct SmoothedState( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we need this specific type? Looks like we might be able to simply use the LdsState class to represent the smoothed state.
| [ResetCombinator] | ||
| [Description("Updates the parameters of a Kalman filter model instance using the provided Kalman filter parameters.")] | ||
| [WorkflowElementCategory(ElementCategory.Sink)] | ||
| public class UpdateParameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public class UpdateParameters | |
| public class UpdateKalmanFilterParameters |
Should this be renamed for consistency with the Save/Load methods?
d041405 to
f857e16
Compare
eeb66f6 to
a237e2c
Compare
…dation during initialization
…imating neural latents
…ges locally to free up space on test runner
…osed to running both the Python and Bonsai code to save memory
…avor of using simpler LDS state
…` for improved clarity
…Observations` and `numStates` are not provided
… of a tuple of tensors
…her than individual files which is more consistent with other `Bonsai.ML` packages
…ved validation logic outside of `KalmanFilter` module
… folder instead of individual file paths
…System` struct instead
…vided by parameters
…including moving devices, setting scalar types, and setting gradient tracking
…property during model creation
…be loaded without explicitly setting type and fixed path support
a237e2c to
faca4ca
Compare
Summary
This PR introduces a new package,
Bonsai.ML.Torch.LDS, which implements linear dynamical systems (LDS) using TorchSharp for online filtering, smoothing, and parameter estimation in Bonsai. This package differs from theBonsai.ML.LinearDynamicalSystemspackage in that it does not depend on Python, and the models parameters can be customised. A test was added to compare the output of the TorchSharp implementation with the output of thelds_pythonpackage following parameter estimation and filtering of neural recordings.The PR in #77 should be merged first.
Refactoring the unit test to download the expected results instead of generating them with a Python script fixes #75