C3W1 Error in programming Assignment evaluation

The programming assigment has an error in 186

should be

#for line in eval_lines[1:3]:
eval_text = "\n".join(eval_lines)
eval_ids = line_to_tensor(eval_text, vocab)
input_ids, target_ids = split_input_target(eval_ids)

preds, status = model(tf.expand_dims(input_ids, 0), training=False, states=None, return_state=True)

#Get the log perplexity
log_ppx = log_perplexity(preds, tf.expand_dims(target_ids, 0))
print(f'The log perplexity and perplexity of your model are {log_ppx} and {np.exp(log_ppx)} respectively')

instead of

eval_text = "\n".join(eval_lines)
eval_ids = line_to_tensor([eval_text], vocab)
input_ids, target_ids = split_input_target(tf.squeeze(eval_ids, axis=0))

preds, status = model(tf.expand_dims(input_ids, 0), training=False, states=None, return_state=True)

#Get the log perplexity
log_ppx = log_perplexity(preds, tf.expand_dims(target_ids, 0))
print(f'The log perplexity and perplexity of your model are {log_ppx} and {np.exp(log_ppx)} respectively')

note line_to_tensor get a string (concat lines with ā€˜\nā€™) and no squeez is necessary

Hi @ArminJ,

Thank you for your feedback. I agree that your suggestion to directly pass a string to line_to_tensor is indeed more efficient and aligns better with the funtcion usage. I will edit the assignment.

Thanks,
Lucas