logo
Loading...

如何解決DimensionMismatch("Input channels must match! (3 vs. 1)") - Cupoy

1epochs = 502@epochs epochs Flux.train!(loss, para...

如何解決DimensionMismatch("Input channels must match! (3 vs. 1)")

2020/05/08 06:49 AM
Julia程式語言論壇
Marc Juang
觀看數:0
回答數:1
收藏數:0

1

epochs = 50

2

@epochs epochs Flux.train!(loss, params(model), train, ADAM(0.005), cb=throttle(evalcb, 10))


┌ Info: Epoch 1 └ @ Main C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\optimise\train.jl:121 


DimensionMismatch("Input channels must match! (3 vs. 1)")  Stacktrace:  [1] DenseConvDims(::NTuple{4,Int64}, ::NTuple{4,Int64}; stride::Tuple{Int64,Int64}, padding::Tuple{Int64,Int64}, dilation::Tuple{Int64,Int64}, flipkernel::Bool) at C:\Users\Marc Juang\.julia\packages\NNlib\FAI3o\src\dim_helpers\DenseConvDims.jl:28  [2] #DenseConvDims#7 at C:\Users\Marc Juang\.julia\packages\NNlib\FAI3o\src\dim_helpers\DenseConvDims.jl:52 [inlined]  [3] #adjoint#1816 at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\lib\nnlib.jl:17 [inlined]  [4] _pullback at C:\Users\Marc Juang\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:53 [inlined]  [5] Conv at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\layers\conv.jl:60 [inlined]  [6] _pullback(::Zygote.Context, ::Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}}, ::Array{Float32,4}) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0  [7] applychain at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\layers\basic.jl:36 [inlined]  [8] _pullback(::Zygote.Context, ::typeof(Flux.applychain), ::Tuple{Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},typeof(flatten),Dense{typeof(relu),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}},Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}},typeof(softmax)}, ::Array{Float32,4}) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0  [9] Chain at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\layers\basic.jl:38 [inlined]  [10] _pullback(::Zygote.Context, ::Chain{Tuple{Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},Conv{2,2,typeof(relu),CuArray{Float32,4,Nothing},CuArray{Float32,1,Nothing}},MaxPool{2,4},typeof(flatten),Dense{typeof(relu),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}},Dense{typeof(identity),CuArray{Float32,2,Nothing},CuArray{Float32,1,Nothing}},typeof(softmax)}}, ::Array{Float32,4}) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0  [11] loss at .\In[7]:1 [inlined]  [12] _pullback(::Zygote.Context, ::typeof(loss), ::Array{Float32,4}, ::Flux.OneHotMatrix{Array{Flux.OneHotVector,1}}) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0  [13] adjoint at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\lib\lib.jl:179 [inlined]  [14] _pullback at C:\Users\Marc Juang\.julia\packages\ZygoteRules\6nssF\src\adjoint.jl:47 [inlined]  [15] #17 at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\optimise\train.jl:89 [inlined]  [16] _pullback(::Zygote.Context, ::Flux.Optimise.var"#17#25"{typeof(loss),Tuple{Array{Float32,4},Flux.OneHotMatrix{Array{Flux.OneHotVector,1}}}}) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface2.jl:0  [17] pullback(::Function, ::Zygote.Params) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface.jl:174  [18] gradient(::Function, ::Zygote.Params) at C:\Users\Marc Juang\.julia\packages\Zygote\YeCEW\src\compiler\interface.jl:54  [19] macro expansion at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\optimise\train.jl:88 [inlined]  [20] macro expansion at C:\Users\Marc Juang\.julia\packages\Juno\f8hj2\src\progress.jl:134 [inlined]  [21] train!(::typeof(loss), ::Zygote.Params, ::DataLoader, ::ADAM; cb::Flux.var"#throttled#20"{Flux.var"#throttled#16#21"{Bool,Bool,typeof(evalcb),Int64}}) at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\optimise\train.jl:81  [22] top-level scope at C:\Users\Marc Juang\.julia\packages\Flux\Fj3bt\src\optimise\train.jl:122  [23] top-level scope at C:\Users\Marc Juang\.julia\packages\Juno\f8hj2\src\progress.jl:134  [24] top-level scope at In[10]:2