KnetML / Neural-Style-Transfer

Knet Implementation of Neural Style Transfer
5 stars 0 forks source link

example does not work under Julia >= 1.0 #3

Open obviousnic opened 4 years ago

obviousnic commented 4 years ago

I made some obvious syntax changes to get the example to run under julia 1.3/Knet 132, but it fails with this error

ERROR: LoadError: MethodError: Cannot `convert` an object of type UnitRange{Int64} to an object of type Colon
Closest candidates are:
  convert(::Type{T}, ::T) where T at essentials.jl:167
Stacktrace:
 [1] convert(::Type{Tuple{Colon,UnitRange{Int64},Colon,Colon}}, ::Tuple{UnitRange{Int64},Colon,Colon,Colon}) at ./essentials.jl:304
 [2] setindex!(::Array{Tuple{Colon,UnitRange{Int64},Colon,Colon},1}, ::Tuple{UnitRange{Int64},Colon,Colon,Colon}, ::Int64) at ./array.jl:766
 [3] copyto!(::Array{Tuple{Colon,UnitRange{Int64},Colon,Colon},1}, ::Int64, ::Array{Tuple{UnitRange{Int64},Colon,Colon,Colon},1}, ::Int64, ::Int64) at ./abstractarray.jl:842
 [4] append!(::Array{Tuple{Colon,UnitRange{Int64},Colon,Colon},1}, ::Array{Tuple{UnitRange{Int64},Colon,Colon,Colon},1}) at ./array.jl:895
 [5] addto!(::AutoGrad.Sparse{Float64,4}, ::AutoGrad.Sparse{Float64,4}) at /root/.julia/packages/AutoGrad/pTNVv/src/addto.jl:44
 [6] #differentiate#3(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(AutoGrad.differentiate), ::Function, ::Param{KnetArray{Float64,4}}, ::Vararg{Any,N} where N) at /root/.julia/packages/AutoGrad/pTNVv/src/core.jl:166
 [7] differentiate(::Function, ::Param{KnetArray{Float64,4}}, ::Vararg{Any,N} where N) at /root/.julia/packages/AutoGrad/pTNVv/src/core.jl:135
 [8] (::getfield(AutoGrad, Symbol("##gradfun#6#8")){typeof(loss),Int64,Bool})(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::getfield(AutoGrad, Symbol("#gradfun#7")){getfield(AutoGrad, Symbol("##gradfun#6#8")){typeof(loss),Int64,Bool}}, ::KnetArray{Float64,4}, ::Vararg{Any,N} where N) at /root/.julia/packages/AutoGrad/pTNVv/src/core.jl:225
 [9] (::getfield(AutoGrad, Symbol("#gradfun#7")){getfield(AutoGrad, Symbol("##gradfun#6#8")){typeof(loss),Int64,Bool}})(::KnetArray{Float64,4}, ::Vararg{Any,N} where N) at /root/.julia/packages/AutoGrad/pTNVv/src/core.jl:221
 [10] style_transfer(::String, ::String, ::Int64, ::Int64, ::Int64, ::Float64, ::NTuple{5,Int64}, ::Array{Float64,1}, ::Float64, ::Bool) at /work/neural_style_transfer.jl:365
 [11] style_transfer(::String, ::String, ::Int64, ::Int64, ::Int64, ::Float64, ::NTuple{5,Int64}, ::Array{Float64,1}, ::Float64) at /work/neural_style_transfer.jl:329
 [12] top-level scope at util.jl:156
 [13] include at ./boot.jl:328 [inlined]
 [14] include_relative(::Module, ::String) at ./loading.jl:1094
 [15] include(::Module, ::String) at ./Base.jl:31
 [16] include(::String) at ./client.jl:431
 [17] top-level scope at REPL[1]:1
in expression starting at /work/neural_style_transfer.jl:397
cemilcengiz commented 4 years ago

Hi, can you please share more details about the problem, and the full notebook you are working on?

obviousnic commented 4 years ago

Helo,

thank you

 

I am attaching a notebook that shows the problem. In this notebook I modified your code to remove the obvious syntax errors fur julia1+.

 

It produces the autograd related error when it gets to the last cell, when running under Julia1.3.

 

(Under Julia1.02, the version of imagenet.jl that it finds is not updated to julia1+, so there are additional errors there).

 

I had also tried to modify to use the newer @diff style autograd interface, which did not work either (I think it gave the same erorr).    

Sent: Tuesday, December 31, 2019 at 1:31 AM From: "cemilcengiz" notifications@github.com To: KnetML/Neural-Style-Transfer Neural-Style-Transfer@noreply.github.com Cc: obviousnic obviousnic@gmx.com, Author author@noreply.github.com Subject: Re: [KnetML/Neural-Style-Transfer] example does not work under Julia >= 1.0 (#3)

Hi, can you please share more details about the problem, and the full notebook you are working on?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

cemilcengiz commented 4 years ago

Hi, apparently you failed to attach the notebook. Can you try adding the code to the comment or sharing it with gist instead?

obviousnic commented 4 years ago

 

Oh sorry for that.

 

Now it is attached I hope :)

 

Sent: Sunday, January 05, 2020 at 7:14 AM From: "cemilcengiz" notifications@github.com To: KnetML/Neural-Style-Transfer Neural-Style-Transfer@noreply.github.com Cc: obviousnic obviousnic@gmx.com, Author author@noreply.github.com Subject: Re: [KnetML/Neural-Style-Transfer] example does not work under Julia >= 1.0 (#3)

Hi, apparently you failed to attach the notebook. Can you try adding the code to the comment or sharing it with gist instead?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

cemilcengiz commented 4 years ago

Nope, I have still not received it. Maybe, attachment is not supported for github issue replies via e-mail.

obviousnic commented 4 years ago

That is strange. Yes I guess attachments are not possible.

 

Anyway, it is easy to see the problem. Just try to run your notebook inside Julia1.3  (or any >= 1.0),

there are several problems.

 

Some are just syntax changes from 0.6, but the autodiff error I cannot figure out.

 

   

Sent: Saturday, January 11, 2020 at 8:14 AM From: "cemilcengiz" notifications@github.com To: KnetML/Neural-Style-Transfer Neural-Style-Transfer@noreply.github.com Cc: obviousnic obviousnic@gmx.com, Author author@noreply.github.com Subject: Re: [KnetML/Neural-Style-Transfer] example does not work under Julia >= 1.0 (#3)

Nope, I have still not received it. Maybe, attachment is not supported for github issue replies via e-mail.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.