Skip to content
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

First pass for ARHMM #123

Open
wants to merge 8 commits into
base: gd/ar
Choose a base branch
from
Open

First pass for ARHMM #123

wants to merge 8 commits into from

Conversation

fausto-mpj
Copy link

I have not changed the sampling function yet, and the results are not checked for correctness. In the version, I just made sure that the changes you first implemented are running without any explicit error.

Copy link
Owner

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fausto-mpj for being willing to contribute! I'm excited to work on this with you.
I didn't look at the content yet (the tests are failing anyway) but I started with some advice on good PR practices. Since I don't know how experienced you are with Julia and GitHub, I made very broad remarks, so don't take them personally :)

src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
test/arhmm_testing_plutonotebook.jl Outdated Show resolved Hide resolved
@fausto-mpj
Copy link
Author

I'm finishing the second pass today (probably), but this time I will run the tests before re-submitting the PR. I have some questions about the code and I will submit them together with the PR.

(Some of them are already written as comments in my last commit, but I will organize them later to make it easier to review!)

@gdalle
Copy link
Owner

gdalle commented Nov 25, 2024

Awesome, thank you!

@fausto-mpj
Copy link
Author

I'm having some issues with (1) the allocation tests, (2) Baum-Welch convergence, and (3) the autodiff test.

With respect to (1), I believe it is due to changes in the _params_and_loglikelihoods function in chainrules.jl (line 11), but I'm not sure. I don't remember changing anything that would allocate instead of using your in-place operations.

Now, (2) and (3) I believe are correlated and both mostly affect autodiff.jl. I barely changed the files for the examples... I just adapted them to the changes in the inference code, but now they aren't working properly according to the tests.

The changes in inference were mostly to adapt for the presence of control and prev_obs, except for some parts where I changed the index of the control variable in the transition_matrix function. The reason for these are in forward.jl, line 106. I'm not sure if I understood correctly, but if the transition matrix is from t to t+1, then some indices were off, as the index of the control variable should match the next step ( t+1): $P(X_{t+1} \vert X_{t}, U_{t+1})$.

I will keep trying tomorrow, but a second pair of eyes would be wonderful!

@gdalle
Copy link
Owner

gdalle commented Dec 1, 2024

Thank you for this, and sorry for the delay. I'll try to take a look this week.

@fausto-mpj
Copy link
Author

I've also finished the $n$-best Viterbi (aka List Viterbi) in a new file (list_viterbi.jl), with a little modification in the linalg.jl (I've only added an argmaxplus_transmul! function with an additional parameter to rank the $n$ best candidates at each t). I tried my best to make it match your code style in viterbi.jl.

The reference paper is here.

The reference implementation (in Python) is here. I've used this as a "ground truth" to test the results of list_viterbi.jl.

Do you want me to commit these changes to this branch, or make a different PR?

@gdalle
Copy link
Owner

gdalle commented Dec 5, 2024

Do you want me to commit these changes to this branch, or make a different PR?

I think these should definitely go in a separate PR (and that PR will be much easier to review too)

@fausto-mpj
Copy link
Author

Got it! As soon as we finished this one, I will adjust whatever is necessary and submit the List Viterbi in a different PR.

@gdalle gdalle deleted the branch gdalle:gd/ar December 6, 2024 06:30
@gdalle gdalle closed this Dec 6, 2024
@gdalle gdalle reopened this Dec 6, 2024
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.95%. Comparing base (fc44a53) to head (4c1b890).

Files with missing lines Patch % Lines
src/types/abstract_hmm.jl 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##            gd/ar     #123      +/-   ##
==========================================
- Coverage   95.27%   94.95%   -0.33%     
==========================================
  Files          18       18              
  Lines         508      515       +7     
==========================================
+ Hits          484      489       +5     
- Misses         24       26       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Owner

@gdalle gdalle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! As a general rule, you probably want to disrupt existing code as little as possible when you make a contribution, and abide by the interfaces that are already there. In this instance, this implies

  • using the same convention for time indices
  • avoiding overloads for Base functions like size which do something unexpected

src/inference/forward.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
src/types/abstract_hmm.jl Outdated Show resolved Hide resolved
@gdalle gdalle mentioned this pull request Dec 6, 2024
@fausto-mpj fausto-mpj requested a review from gdalle December 9, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants