-
Notifications
You must be signed in to change notification settings - Fork 18
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
Added dual prices for the probability simplex and the unit simplex #15
Changes from 5 commits
7b9d83f
b9769bf
7d014c3
a76f656
e30ae44
f99d172
310a1a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import FrankWolfe | |
import LinearAlgebra | ||
|
||
|
||
n = Int(1e5); | ||
n = Int(1e6); | ||
|
||
xpi = rand(n); | ||
total = sum(xpi); | ||
|
@@ -13,11 +13,11 @@ const grad(x) = 2 * (x-xp) | |
|
||
|
||
function cf(x,xp) | ||
return LinearAlgebra.norm(x-xp)^2 | ||
return @. LinearAlgebra.norm(x-xp)^2 | ||
end | ||
|
||
function cgrad(x,xp) | ||
return 2 * (x-xp) | ||
function cgrad(x,xp) | ||
return @. 2 * (x-xp) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here: they basically halve the memory allocs when you broadcast: without broadcast:
with broadcasting
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done for the gradient here as example |
||
end | ||
|
||
lmo_prob = FrankWolfe.ProbabilitySimplexOracle(1); | ||
|
@@ -26,3 +26,4 @@ x0 = FrankWolfe.compute_extreme_point(lmo_prob, zeros(n)); | |
FrankWolfe.benchmarkOracles(f,grad,lmo_prob,n;k=100,T=Float64) | ||
|
||
FrankWolfe.benchmarkOracles(x -> cf(x,xp),x -> cgrad(x,xp),lmo_prob,n;k=100,T=Float64) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure the broadcast will be needed here,
x
andxp
should have the same dimensions right?x - xp
works for vectors x and xp, it will only error if one of them is a scalarThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point - saves half the memory though 126MB vs. 63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok curious, well let's leave it as-is then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am not sure yet that i understand where the grossly different allocations come from with and without broadcasting. see numbers below