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

Improve aggregation speeds by using eachindex instead of iterate #173

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

MilesCranmer
Copy link
Contributor

This changes from e.g.,

  sum(loss(ŷ, y) for (ŷ, y) in zip(outputs, targets))

to

  sum(i -> loss(outputs[i], targets[i]), eachindex(outputs, targets))

which improves speeds by ~3.5x. Fixes #172

@MilesCranmer MilesCranmer changed the title Improve aggregation speeds by summing function Improve aggregation speeds by using eachindex instead of iterate Aug 24, 2023
@juliohm juliohm merged commit 0b3e74f into JuliaML:master Aug 24, 2023
7 checks passed
@MilesCranmer MilesCranmer deleted the fix-sum-speeds branch August 24, 2023 12:10
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.

Very slow loss aggregation
2 participants