Viterbi_forward (# UNQ_C6) problem with best_path_i

Hi, can you please tell me what’s wrong?

TypeError Traceback (most recent call last)
in
1 # this will take a few minutes to run => processes ~ 30,000 words
----> 2 best_probs, best_paths = viterbi_forward(A, B, prep, best_probs, best_paths, vocab)

in viterbi_forward(A, B, test_corpus, best_probs, best_paths, vocab, verbose)
64 # into best_paths matrix, for the POS tag of the current word
65 # and the position of the current word inside the corpus.
—> 66 best_paths[j,i] = best_path_i
67
68 ### END CODE HERE ###

TypeError: int() argument must be a string, a bytes-like object or a number, not ‘NoneType’

hi @Doron_Modan

Please DM the screenshot of codes related to the grade cell in question. Click on my name and then message.

please do not post any codes here as it is against community guidelines.

Regards
DP

It sounds like a similar situation to this earlier thread.

Regardng that earlier thread, it seems I replaced all the NONE statements, except for this:
# Initialize best_path for current word i to None
best_path_i = None # Do not replace this None # @KEEPTHIS

The evidence of the error message suggests otherwise. Are you getting that message from the grader or from the tests directly in the notebook? One possibility is that the runtime state of your notebook is inconsistent somehow.

Try this sequence:

Kernel -> Restart and Clear Output
Save
Cell -> Run All

Do you still see the error?

hi @Doron_Modan

The issue lies in the below code

Calculate the probability = None
best probs of POS tag k, previous word i-1 +
log(prob of transition from POS k to POS j) +
log(prob that emission of POS j is word i)

YOU HAVE USED INCORRECT CALL ARGUMENTS assigned for this grade cell for best_prob and used the best_prob_i from the previous step recalled.

Check the formula just given before the exercise viterbi_forward which mentions the correct formula to be used, i.e. best_prob[k, i-1]

Regards
DP

1 Like