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

Change onehot to oneelement #26

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Change onehot to oneelement #26

wants to merge 3 commits into from

Conversation

mtfishman
Copy link
Member

onehot isn't quite right for the ITensor constructor that creates a tensor with a single nonzero element, see OneHotArrays.jl.

There is precedent from FillArrays.jl and Zygote.jl for calling a sparse array with a single nonzero element OneElement (https://github.com/JuliaArrays/FillArrays.jl), so here I am changing onehot to oneelement.

See also #5, ITensor/SparseArraysBase.jl#24.

Copy link

codecov bot commented Feb 2, 2025

Codecov Report

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

Project coverage is 50.53%. Comparing base (e9f1be2) to head (5576de1).

Files with missing lines Patch % Lines
src/quirks.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #26      +/-   ##
==========================================
+ Coverage   46.23%   50.53%   +4.30%     
==========================================
  Files           5        5              
  Lines         186      186              
==========================================
+ Hits           86       94       +8     
+ Misses        100       92       -8     
Flag Coverage Δ
docs 22.70% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@emstoudenmire
Copy link

I see what you mean. Just from the name "one hot" I would have thought things like having multiple ones and a single row or column would be forbidden (here I am referring to the example at that link). But apparently this is the usage in ML, and also one element is just a much clearer name.

@mtfishman
Copy link
Member Author

I see what you mean. Just from the name "one hot" I would have thought things like having multiple ones and a single row or column would be forbidden (here I am referring to the example at that link). But apparently this is the usage in ML, and also one element is just a much clearer name.

They call that more general case a onehotbatch in OneHotArrays.jl, but still you can see the idea is to find the location of a value in a collection and use that to define a basis vector, so it is a very similar concept to how we use onehot but the application is a bit different. Anyway, I'll probably bring back onehot for backwards compatibility but deprecate it in favor of oneelement.

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