Skip to content

Commit

Permalink
fix: allow vectors as input to hamiltonian nn
Browse files Browse the repository at this point in the history
  • Loading branch information
avik-pal committed Aug 28, 2024
1 parent 38eb87b commit 70c9d22
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/layers/hamiltonian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ end

hamiltonian_forward(::AutoForwardDiff, model, x) = ForwardDiff.gradient(sum model, x)

function (hnn::HamiltonianNN)(x::AbstractVector, ps, st)
y, stₙ = hnn(reshape(x, :, 1), ps, st)
return vec(y), stₙ
end

function (hnn::HamiltonianNN{FST})(x::AbstractArray{T, N}, ps, st) where {FST, T, N}
model = StatefulLuxLayer{FST}(hnn.model, ps, st.model)

Expand Down

2 comments on commit 70c9d22

@avik-pal
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/114032

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.1 -m "<description of version>" 70c9d22b15bb238bfd2b2c6438302ac7cd6f3d86
git push origin v0.4.1

Please sign in to comment.