# Programming Assignment: Programming Assignment: Question Answering - C4W3 Many warning in unit test

**URL:** <https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965>\
**Category:** NLP with Attention Models\
**Tags:** week-module-3\
**Created:** [February 1, 2025, 7:58am UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965 "2025-02-01T07:58:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 1, 2025, 7:58am UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/1 "2025-02-01T07:58:22Z")

</div>

I encountered many warnings in unit test. I unable to get the Expected output.

I hope you can help me on this. Thanks in advance.

 ![2025-02-01_15-53-11](https://global.discourse-cdn.com/dlai/original/3X/6/5/654a743c061e08c6a5d24f817509a9d6456c0ebd.png)

---

<div class="post-metadata">

**Author:** ![SNaveenMathew](https://avatars.discourse-cdn.com/v4/letter/s/a587f6/32.png) [@SNaveenMathew](https://community.deeplearning.ai/u/SNaveenMathew)\
**Post date:** [February 3, 2025, 12:48am UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/2 "2025-02-03T00:48:38Z")

</div>

I found this discussion on Stack Overflow:

> <https://stackoverflow.com/questions/58289342/tf2-0-translation-model-error-when-restoring-the-saved-model-unresolved-objec>

Were you trying to load a model checkpoint to run prediction?

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [February 3, 2025, 1:10am UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/3 "2025-02-03T01:10:08Z")

</div>

@chenkhoon

try to disconnect and reconnect the kernel, then run the cell from beginning till the unittest you encountered this output, if you still are getting same output, then let me know.

my also suspicion would be that you might have made changes in the assignment codes that you weren’t suppose to. in case you made any changes other than just writing codes with the already instructions given, then get a fresh copy and re-do your assignments. Please make sure only to write codes between the assigned markers ###START AND END CODE HERE### with instructions already given when you open the notebook.

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 11:43am UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/4 "2025-02-03T11:43:14Z")

</div>

I am implementing a “question-answering function using a Transformer model” in “TensorFlow”.

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 12:05pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/5 "2025-02-03T12:05:33Z")

</div>

I have re-done the cell by missing the missing code as follows

it still show me the error.

 ![Error](https://global.discourse-cdn.com/dlai/original/3X/8/5/855d96c9b6e8ed40ce033e284e9b51bde4f3e2a0.png)

def answer\_question(question, model, tokenizer, encoder\_maxlen=150, decoder\_maxlen=50):  
A function for question answering using the transformer model  
Arguments:  
question (tf.Tensor): Input data with question and context  
model (tf.keras.model): The transformer model  
tokenizer (function): The SentencePiece tokenizer  
encoder\_maxlen (number): Max length of the encoded sequence  
decoder\_maxlen (number): Max length of the decoded sequence  
Returns:  
(str): The answer to the question

**Codes removed, against community guidelines.**

```
return tokenized_answer

```

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 12:07pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/6 "2025-02-03T12:07:11Z")

</div>

By the way I also restarted the kernel and clear all output cell. Please advise me further on this.

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [February 3, 2025, 12:08pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/7 "2025-02-03T12:08:20Z")

</div>

don’t post codes here @chenkhoon.  
kindly DM me screenshot of the codes by personal DM. click on my name and then message.

I noticed many of the codes are left with None. why have you not written codes completely??

Remember the codes given come with some instructions and already given part of the codes with **None**

those None need to be replaced with your codes, only time None need to be left when in the instructions it is mentioned to be left None as it is.

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 12:22pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/8 "2025-02-03T12:22:56Z")

</div>

I did nott post the code. What I posted is the original code. Please advise how can I DM you my code?

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 12:27pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/9 "2025-02-03T12:27:20Z")

</div>

I DM you my code already…

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [February 3, 2025, 12:27pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/10 "2025-02-03T12:27:23Z")

</div>

oh ok. 😂 smart

you can send me code by DM

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/178017_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [February 3, 2025, 12:47pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/11 "2025-02-03T12:47:38Z")

</div>

@chenkhoon

Errors in your codes  
for code line

1. Predict the next word using the model, the input document and the current state of output

you are using a global variable for the model, remember for the answer\_question code cell, the assigned variable name for model

model (tf.keras.model): The transformer model

1. for code  
Concat the predicted next word to the output  
your axis is incorrect, remember you have to predict the next word and not the previous word.

2. for code line  
The text generation stops if the model predicts the EOS token

your if statement should satisfy the below condition

Stop Condition:

The text generation stops if the model predicts the EOS token.  
If the EOS token is predicted, break out of the loop.

if your next is absolute equal to eos, then break the loop.(you do not require to mention any other numpy or indexing for this code.

---

<div class="post-metadata">

**Author:** ![chenkhoon](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@chenkhoon](https://community.deeplearning.ai/u/chenkhoon)\
**Post date:** [February 3, 2025, 1:05pm UTC](https://community.deeplearning.ai/t/programming-assignment-programming-assignment-question-answering-c4w3-many-warning-in-unit-test/761965/12 "2025-02-03T13:05:27Z")

</div>

Thanks for the advice. Resolved with great thanks
