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

Expected param size (1150, 1) got (1150,) (BinSentimentClassifier) #35

Open
Broever101 opened this issue Jul 28, 2022 · 1 comment
Open

Comments

@Broever101
Copy link

Broever101 commented Jul 28, 2022

Multiple issues with this one. Line 34 has SentimentClassifier which isn't defined anywhere which should be BinSentimentClassifier.
Moreover TextModels does not include the sentiment.jl file where BinSentimentClassifier is defined.
And then running this:

julia> using TextModels.ULMFiT

julia> c = ULMFiT.BinSentimentClassifier()
ERROR: Expected param size (1150, 1), got (1150,)
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] loadparams!(m::TextModels.ULMFiT.BinSentimentClassifier, xs::Vector{Any})
   @ Flux C:\Users\Admin\.julia\packages\Flux\BPPNj\src\functor.jl:59
 [3] TextModels.ULMFiT.BinSentimentClassifier()
   @ TextModels.ULMFiT C:\Users\Admin\Desktop\work\TweetClassification\dev\TextModels\src\ULMFiT\sentiment.jl:75
 [4] top-level scope
   @ REPL[5]:1
 [5] top-level scope
   @ C:\Users\Admin\.julia\packages\CUDA\DfvRa\src\initialization.jl:52

Running the following below line 49 of ULMFiT/sentiment.jl:

i = 0
for (p, x) in zip(Flux.params(sc), weights)
    println("Iteration ", i)
    println("size(p): ", size(p))
    println("size(x): ", size(x))
    size(p) == size(x) || 
        error("Expected param size (size(p)), got (size(x))")
    i += 1
    println()
end

I get

image

Any workaround/solution?

@Broever101
Copy link
Author

Broever101 commented Jul 28, 2022

So these are all the weights that are out of shape

weights[5] = reshape(weights[5], (1150, 1))
weights[6] = reshape(weights[6], (1150, 1))
weights[10] = reshape(weights[10], (1150, 1))
weights[11] = reshape(weights[11], (1150, 1))
weights[15] = reshape(weights[15], (400, 1))
weights[16] = reshape(weights[16], (400, 1))

Setting them right and the end result:
image

What am I missing? This doesn't align with the docstring.

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

1 participant