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

Add EmbeddingBag #2031

Merged
merged 23 commits into from
Apr 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
doc fix
mcognetta committed Aug 2, 2022
commit c437e2e19e31dacbe68cc852f0fda1380de34ee4
6 changes: 3 additions & 3 deletions src/layers/basic.jl
Original file line number Diff line number Diff line change
@@ -722,11 +722,11 @@ The inputs can take several forms:
julia> vocab_size, embed_size = 1000, 4;

julia> model = Flux.EmbeddingBag(vocab_size => embed_size)
Embedding(1000 => 4) # 4_000 parameters
EmbeddingBag(1000 => 4) # 4_000 parameters

julia> bags = [[1, 200, 25, 789], [2, 5, 10, 999]];

julia> bags_mtx = [1 2; 200 5; 25 10; 789 999]
julia> bags_mtx = [1 2; 200 5; 25 10; 789 999];

julia> model(bags) |> summary
"4×2 Matrix{Float32}"
@@ -772,4 +772,4 @@ end

function Base.show(io::IO, m::EmbeddingBag)
print(io, "EmbeddingBag(", size(m.weight, 2), " => ", size(m.weight, 1), ")")
end
end