[C3_W4_Assignment] Classify Model - TypeError: cannot unpack non-iterable NoneType object

Hello everyone,

I am working on the C3_W4_Assignment and I can’t get Exercise 05 ‘Classify’ and Exercise 06 ‘Predict’ to work.
When testing the functions with w4_unittest, I get this error:


TypeError Traceback (most recent call last)
in
1 # Test your function
----> 2 w4_unittest.test_classify(classify, vocab, data_generator)

~/work/w4_unittest.py in test_classify(target, vocab, data_generator)
1345
1346 for test_case in test_cases:
→ 1347 result = target(**test_case[“input”])
1348
1349 try:

in classify(test_Q1, test_Q2, y, threshold, model, vocab, data_generator, batch_size)
27 y_test = y[i:i + batch_size]
28 # Call the model
—> 29 v1, v2 = model((q1, q2))
30
31 for j in range(batch_size):

TypeError: cannot unpack non-iterable NoneType object

Did someone else come across this error? I do not understand what I’m doing wrong since I am passing two batches to the model

Thank you.
Cheers,
Rafaela

I have not done this course, so I don’t know this code. But notice that what you passed to model is actually a single argument, which is a “tuple” with two elements. Is that what you intended?

The first rule of debugging is “believe the error message, because that’s the best thing you’ve got to start with”. So what does that mean? Maybe model expects two arguments?

Good news.
I solved this by setting vocab[’ <PAD> ‘] instead of vocab[’'] :slight_smile:

Thank you for your response Paul.
There is not a lot of documentation on how to run the trax’s Parallel model for inference but I’ve found that we are supposed to add both question lists as a tuple.
The problem was actually related to the ‘pad’ argument of the data generator.

Ok, sorry, as I mentioned, I don’t know that code. Glad to hear you found the solution under your own power! Cheers! :nerd_face: