#C3W1 Assignment - perplexity score

Hello @q3nius

With what other mentor has provided link.

also notice for pred.shape instructions provided as hint were

  • To convert the target into the same dimension as the predictions tensor use tf.one_hot with target and preds.shape[-1].
  • You will also need the np.equal function in order to unpad the data and properly compute perplexity.

Also refer this to assign the corrective axis value for the perplexity score.

If the input indices is rank N , the output will have rank N+1 . The new axis is created at dimension axis (default: the new axis is appended at the end). So choosing 1 is incorrect in this scenario.

https://www.tensorflow.org/api_docs/python/tf/one_hot

This link provides detail on correct assign value for axis.

Next make sure
Identify non-padding elements in the target,
You should check if the target equals to PADDING_ID which is 1.

Regards
DP