pluskid / Mocha.jl

Deep Learning framework for Julia
Other
1.29k stars 254 forks source link

Type error in solvers.jl #87

Closed iizukak closed 9 years ago

iizukak commented 9 years ago

I tried examples/test.jl and got under error.

https://gist.github.com/iizukak/b657e0a5fcc98a2ce346

Condition

I noticed test.jl fail at line 50 in test.jl and line 95 in solvers.jl

julia> lr_policy = LRPolicy.Staged(
         (6000, LRPolicy.Fixed(0.001)),
         (4000, LRPolicy.Fixed(0.0001)),
       )

ERROR: MethodError: `convert` has no method matching convert(::Type{Array{T,N}}, ::Tuple{DataType,DataType}, ::Int64)
This may have arisen from a call to the constructor Array{T,N}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  Array{T}(::Type{T}, ::Integer)
  Array{T}(::Type{T}, ::Integer, ::Integer)
  Array{T}(::Type{T}, ::Integer, ::Integer, ::Integer)
  ...
 in call at /Users/kentaro/.julia/v0.4/Mocha/src/solvers.jl:95

after this PR, test.jl run without error.

I noticed same problem at line 183. This code cause under error

julia> MomPolicy.Staged((30000, MomPolicy.Fixed(0.0)),(50000,MomPolicy.Fixed(0.1)),(90000,MomPolicy.Fixed(0.3)),(200000,MomPolicy.Fixed(0.7)),(10000,MomPolicy.Fixed(0.9)))
ERROR: MethodError: `convert` has no method matching convert(::Type{Array{T,N}}, ::Tuple{DataType,DataType}, ::Int64)
This may have arisen from a call to the constructor Array{T,N}(...),
since type constructors fall back to convert methods.
Closest candidates are:
  Array{T}(::Type{T}, ::Integer)
  Array{T}(::Type{T}, ::Integer, ::Integer)
  Array{T}(::Type{T}, ::Integer, ::Integer, ::Integer)
  ...
 in call at /Users/kentaro/.julia/v0.4/Mocha/src/solvers.jl:183

I think 2 problems are fixed in this PR.

pluskid commented 9 years ago

@iizukak Thanks! This is awesome! Actually this is a known "bug" as v0.4 changed the syntax for tuple types. I was trying to fix all of those but since this pattern is difficult to search, I forgot this two spots. Thanks!