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.
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.
I found this discussion on Stack Overflow:
Were you trying to load a model checkpoint to run prediction?
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.
I am implementing a “question-answering function using a Transformer model” in “TensorFlow”.
I have re-done the cell by missing the missing code as follows
it still show me the error.
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
By the way I also restarted the kernel and clear all output cell. Please advise me further on this.
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.
I did nott post the code. What I posted is the original code. Please advise how can I DM you my code?
I DM you my code already…
oh ok. smart
you can send me code by DM
Errors in your codes
for code line
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
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.
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.
Thanks for the advice. Resolved with great thanks