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

ambiguity error in size(rec, dims...) #18

Closed
CarloLucibello opened this issue Jun 30, 2017 · 1 comment
Closed

ambiguity error in size(rec, dims...) #18

CarloLucibello opened this issue Jun 30, 2017 · 1 comment

Comments

@CarloLucibello
Copy link
Collaborator

CarloLucibello commented Jun 30, 2017

The following code works well

julia> f(x)=(p=size(x); p[1]*sum(x.^2))

julia> grad(f)(ones(3))
3-element Array{Float64,1}:
 6.0
 6.0
 6.0

and also size(x,1) doesn't give any problem, but here I have an ambiguity error

julia> f(x)=(p=size(x,(1,2)...); p[1]*sum(x.^2))

julia> grad(f)(ones(3,2,2,3))
ERROR: MethodError: size(::AutoGrad.Rec{Array{Float64,4}}, ::Int64, ::Int64, ::Int64) is ambiguous. Candidates:
  size{N}(x, d1::Integer, d2::Integer, dx::Vararg{Integer,N}) at abstractarray.jl:48
  size{##305}(x::AutoGrad.Rec{##305}, i...)
 in f(::AutoGrad.Rec{Array{Float64,4}}) at ./REPL[7]:1
 in forward_pass(::Function, ::Tuple{Array{Float64,4}}, ::Array{Any,1}, ::Int64) at /home/carlo/.julia/v0.5/AutoGrad/src/core.jl:88
 in (::AutoGrad.##gradfun#1#3{#f,Int64})(::Array{Any,1}, ::Function, ::Array{Float64,4}, ::Vararg{Array{Float64,4},N}) at /home/carlo/.julia/v0.5/AutoGrad/src/core.jl:39
 in (::AutoGrad.#gradfun#2)(::Array{Float64,4}, ::Vararg{Array{Float64,4},N}) at /home/carlo/.julia/v0.5/AutoGrad/src/core.jl:39
 in eval_user_input(::Any, ::Base.REPL.REPLBackend) at ./REPL.jl:64
 in macro expansion at ./REPL.jl:95 [inlined]
 in (::Base.REPL.##3#4{Base.REPL.REPLBackend})() at ./event.jl:68

This could be fixed easily defining

size(x::AutoGrad.Rec, d1::Integer, d2::Integer, dx::Vararg{Integer}) = size(getval(x), d1, d2, dx...)

as I already tested. If someone points me to the right location where this function should reside I can file a PR.

crossref denizyuret/Knet.jl#139

@denizyuret
Copy link
Owner

denizyuret commented Jun 30, 2017 via email

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

No branches or pull requests

2 participants