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

Add new Models and provide user with an option to fetch untrained models #16

Closed
11 of 18 tasks
avik-pal opened this issue Jul 11, 2018 · 6 comments
Closed
11 of 18 tasks

Comments

@avik-pal
Copy link
Member

avik-pal commented Jul 11, 2018

List of models that I propose to add are:-

  • VGG16
  • VGG16_BN
  • VGG19_BN
  • Resnet18
  • Resnet34
  • Resnet101
  • Resnet152
  • InceptionNet v3
  • InceptionNet v4
  • InceptionResnet v2
  • Densenet BC 169
  • Densenet BC 201
  • Densenet BC 264

The above ones just need a few tweeks before being ported from model-zoo. Also models like:

  • Densenets 121, 161, 169, 201 (non BC ones)
  • Xception
  • ResNeXt
  • Mobilenet v1
  • Mobilenet v2

should be added, but they are not ready in model zoo currently.

The proposed API is something like VGG19 would fetch an untrained model to the user. To get a trained model we use something like trained(VGG19). We will throw an error for trying to fetch models for which we donot have the trained weights (atleast all the above models for now).
cc @MikeInnes

@MikeInnes
Copy link
Member

Sounds good! We can probably just keep a couple of representative examples in the model zoo, and the rest here.

@chriselrod
Copy link

chriselrod commented Oct 26, 2018

EDIT: What I mention below was already discussed here.

I've been getting ERROR: MethodError: no method matching conv(::Array{Float32,4}, ::Array{Float64,4}; stride=(2, 2), pad=(3, 3), dilation=(1, 1)) for models other than VGG19:

julia> resnet = ResNet();
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   602    0   602    0     0   1899      0 --:--:-- --:--:-- --:--:--  1899
100 97.7M  100 97.7M    0     0  4702k      0  0:00:21  0:00:21 --:--:-- 4849k

julia> predict2(resnet, load("Verona2.jpg"))
ERROR: MethodError: no method matching conv(::Array{Float32,4}, ::Array{Float64,4}; stride=(2, 2), pad=(3, 3), dilation=(1, 1))
Closest candidates are:
  conv(::AbstractArray, ::Flux.Tracker.TrackedArray; kw...) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:344
  conv(::Flux.Tracker.TrackedArray, ::AbstractArray; kw...) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:345
  conv(::A<:AbstractArray, ::A<:AbstractArray; pad, stride, dilation) where A<:AbstractArray at /home/celrod/.julia/packages/NNlib/0EAe7/src/conv.jl:28
Stacktrace:
 [1] #_forward#433(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:347
 [2] (::getfield(Flux.Tracker, Symbol("#kw##_forward")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(Flux.Tracker._forward), ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at ./none:0
 [3] #track#1(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::typeof(NNlib.conv), ::Array{Float32,4}, ::Vararg{Any,N} where N) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/Tracker.jl:50
 [4] (::getfield(Flux.Tracker, Symbol("#kw##track")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(Flux.Tracker.track), ::typeof(NNlib.conv), ::Array{Float32,4}, ::Vararg{Any,N} where N) at ./none:0
 [5] #conv#431(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:344
 [6] (::getfield(NNlib, Symbol("#kw##conv")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at ./none:0
 [7] (::Flux.Conv{2,typeof(identity),TrackedArray{…,Array{Float64,4}},TrackedArray{…,Array{Float64,1}}})(::Array{Float32,4}) at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/conv.jl:44
 [8] (::getfield(Flux, Symbol("##60#61")))(::Array{Float32,4}, ::Flux.Conv{2,typeof(identity),TrackedArray{…,Array{Float64,4}},TrackedArray{…,Array{Float64,1}}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/basic.jl:31
 [9] mapfoldl_impl(::typeof(identity), ::getfield(Flux, Symbol("##60#61")), ::NamedTuple{(:init,),Tuple{Array{Float32,4}}}, ::Array{Any,1}) at ./reduce.jl:43
 [10] #mapfoldl#170 at ./reduce.jl:70 [inlined]
 [11] #mapfoldl at ./none:0 [inlined]
 [12] #foldl#171 at ./reduce.jl:88 [inlined]
 [13] #foldl at ./none:0 [inlined]
 [14] Chain at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/basic.jl:31 [inlined]
 [15] ResNet at /home/celrod/.julia/packages/Metalhead/fYeSU/src/resnet.jl:98 [inlined]
 [16] forward(::ResNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}) at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:70
 [17] predict(::ResNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::Int64) at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:93
 [18] predict at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:91 [inlined]
 [19] predict2(::ResNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}) at ./REPL[6]:2

julia> dn = DenseNet();
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   604    0   604    0     0   2228      0 --:--:-- --:--:-- --:--:--  2220
100 31.2M  100 31.2M    0     0  4275k      0  0:00:07  0:00:07 --:--:-- 4896k

julia> ptrn = predict(dn, load("Verona2.jpg"))
ERROR: MethodError: no method matching conv(::Array{Float32,4}, ::Array{Float64,4}; stride=(2, 2), pad=(3, 3), dilation=(1, 1))
Closest candidates are:
  conv(::AbstractArray, ::Flux.Tracker.TrackedArray; kw...) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:344
  conv(::Flux.Tracker.TrackedArray, ::AbstractArray; kw...) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:345
  conv(::A<:AbstractArray, ::A<:AbstractArray; pad, stride, dilation) where A<:AbstractArray at /home/celrod/.julia/packages/NNlib/0EAe7/src/conv.jl:28
Stacktrace:
 [1] #_forward#433(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:347
 [2] (::getfield(Flux.Tracker, Symbol("#kw##_forward")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(Flux.Tracker._forward), ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at ./none:0
 [3] #track#1(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::typeof(NNlib.conv), ::Array{Float32,4}, ::Vararg{Any,N} where N) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/Tracker.jl:50
 [4] (::getfield(Flux.Tracker, Symbol("#kw##track")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(Flux.Tracker.track), ::typeof(NNlib.conv), ::Array{Float32,4}, ::Vararg{Any,N} where N) at ./none:0
 [5] #conv#431(::Base.Iterators.Pairs{Symbol,Tuple{Int64,Int64},Tuple{Symbol,Symbol,Symbol},NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}}, ::Function, ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/tracker/array.jl:344
 [6] (::getfield(NNlib, Symbol("#kw##conv")))(::NamedTuple{(:stride, :pad, :dilation),Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64},Tuple{Int64,Int64}}}, ::typeof(NNlib.conv), ::Array{Float32,4}, ::TrackedArray{…,Array{Float64,4}}) at ./none:0
 [7] (::Flux.Conv{2,typeof(identity),TrackedArray{…,Array{Float64,4}},TrackedArray{…,Array{Float64,1}}})(::Array{Float32,4}) at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/conv.jl:44
 [8] (::getfield(Flux, Symbol("##60#61")))(::Array{Float32,4}, ::Flux.Conv{2,typeof(identity),TrackedArray{…,Array{Float64,4}},TrackedArray{…,Array{Float64,1}}}) at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/basic.jl:31
 [9] mapfoldl_impl(::typeof(identity), ::getfield(Flux, Symbol("##60#61")), ::NamedTuple{(:init,),Tuple{Array{Float32,4}}}, ::Array{Any,1}) at ./reduce.jl:43
 [10] #mapfoldl#170 at ./reduce.jl:70 [inlined]
 [11] #mapfoldl at ./none:0 [inlined]
 [12] #foldl#171 at ./reduce.jl:88 [inlined]
 [13] #foldl at ./none:0 [inlined]
 [14] Chain at /home/celrod/.julia/packages/Flux/rcN9D/src/layers/basic.jl:31 [inlined]
 [15] DenseNet at /home/celrod/.julia/packages/Metalhead/fYeSU/src/densenet.jl:94 [inlined]
 [16] forward(::DenseNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}) at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:70
 [17] predict(::DenseNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}, ::Int64) at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:93
 [18] predict(::DenseNet, ::Array{ColorTypes.RGB{FixedPointNumbers.Normed{UInt8,8}},2}) at /home/celrod/.julia/packages/Metalhead/fYeSU/src/utils.jl:91
 [19] top-level scope at none:0

Is the issue related to ::Array{Float32,4}, ::Array{Float64,4}?

@ven-k
Copy link

ven-k commented Mar 14, 2020

I implemented a skeletal structure of InceptionNet V3, inspired by Pytorch.

  1. I wanted to know which dataset should I train it with.
  2. And the adaptive maxpool, and passing the standard deviation to conv layers is not added to the main Flux. I'm working on that. And on completion will add to my implementation of Inception V3.

@DhairyaLGandhi
Copy link
Member

related #71

@darsnack darsnack unpinned this issue Oct 17, 2021
@darsnack
Copy link
Member

We have a lot of these models now in the repo, and there is a consistent interface for loading the weights. There are some models here that we do not have. Perhaps we can refactor this issue into a clean one with models/weights that we need to add and pin it?

@darsnack
Copy link
Member

darsnack commented Feb 7, 2022

Closing in favor of #112 which is more up to date.

@darsnack darsnack closed this as completed Feb 7, 2022
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

6 participants