C3W4_Assignment.ipynb GRADED FUNCTION: n_gram_seqs -how to get this to return tf.int64 tensors

assignment: https://www.coursera.org/learn/natural-language-processing-tensorflow/programming/GkEhd/predicting-the-next-word

If i follow the examples in the course (labs 1& 2), i can get this function to return a list but not a list of tf.int64 tensors.
Am i supposed to be doing some for of conversion inside this function? Am i supposed to be using tf.convert_to_tensor?? There is no examples of the use of this function in the course

and just to add…Compared to the expected output, my function does not have this text:

[<tf.Tensor: shape=(2,), dtype=int64, numpy=array([

However the content or the array appears correct.

Hi, are you working on the n_gram_seqs function?

Yes thats the one. Is there any reference you could point me to, to convert this to the correct type? Many thanks

i fluked the answer myself. I removed the .numpy() function where i defined a sequence . All examples in the course used this function, so i dont know why we dont use it in this exercise, but once removed, the expected output and actual output were identical. Thank you.!

2 Likes

Good to know. It’s due to the expected returned output. It was specified in the function definition. The assignments try to add another dimension, so the learner can think a bit, and it’s not just copy paste.

2 Likes

well it certainly got me on the copy&paste error! Guilty as charged! :rofl: :rofl: :rofl:

1 Like