-
Notifications
You must be signed in to change notification settings - Fork 120
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
Convex does not support broadcasting #479
Comments
This was referenced Feb 23, 2022
In #717 a documentation warning was added. |
I had another case with type conversion. function SolveSoftSVM1D( vX :: Vector{T}, vY :: Vector{N}, paramC :: T ) where {T <: AbstractFloat, N <: Integer}
numPts = length(vX);
if length(vY) != numPts
throw(DimensionMismatch(lazy"`vY`` has length $(length(vY)), `vX` has length $(length(vX))"));
end
paramW = Variable();
paramB = Variable();
vξ = Variable(numPts);
sConvProb = minimize( T(0.5) * sumsquares(paramW) + paramC * sum(pos(one(T) - T.(vY) .* (paramW * vX + paramB))) );
solve!(sConvProb, ECOS.Optimizer; silent = true);
return paramW.value, paramB.value, vξ.value;
end While changing |
What's the full stack trace of the error? |
Here is an MWE: using Convex;
using ECOS;
function SolveSoftSVM1D( vX :: Vector{T}, vY :: Vector{N}, paramC :: T ) where {T <: AbstractFloat, N <: Integer}
paramW = Variable();
paramB = Variable();
sConvProb = minimize( T(0.5) * sumsquares(paramW) + paramC * sum(pos(one(T) - T.(vY) .* (paramW * vX + paramB))) ); #<! Avoid casting with T.() in expression
solve!(sConvProb, ECOS.Optimizer; silent = true);
return paramW.value, paramB.value;
end
vX = Float64.(collect(-3:3));
vY = [-1, -1, -1, 1, 1, 1, 1];
paramC = 0.0;
paramW, paramB = SolveSoftSVM1D(vX, vY, paramC); If you change ERROR: MethodError: no method matching iterate(::Convex.AdditionAtom)
Closest candidates are:
iterate(::Base.AsyncGenerator, ::Base.AsyncGeneratorState)
@ Base asyncmap.jl:362
iterate(::Base.AsyncGenerator)
@ Base asyncmap.jl:362
iterate(::LibGit2.GitRevWalker)
@ LibGit2 D:\Applications\JuliaWin\packages\julia\share\julia\stdlib\v1.10\LibGit2\src\walker.jl:29
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Convex.jl lacks support for a lot of broadcasting operations.
This causes a bunch of problems like this:
The purpose of this issue is to collate the currently open issues into a single thread, and to make it more discoverable for users coming to report bugs.
Replaces:
The text was updated successfully, but these errors were encountered: