Hello @arvyzukai
NameError Traceback (most recent call last)
Cell In[171], line 5
3 question2 = “When can I see you again?”
4 # 1 means it is duplicated, 0 otherwise
----> 5 predict(question1 , question2, 0.7, model, verbose = True)
Cell In[170], line 26, in predict(question1, question2, threshold, model, verbose)
23 v2 = v1v2[0]
24 # Take the dot product to compute cos similarity of each pair of entries, v1, v2
25 # Since v1 and v2 are both vectors, use the function tf.math.reduce_sum instead of tf.linalg.matmul
—> 26 d = tf.math.reduce_sum(v1[j]*v2[j])
27 # Is d greater than the threshold?
28 res = d>threshold
NameError: name ‘j’ is not defined
The below test failed as I edited out the j range from the code, I got the below result on running the test cell
Wrong prediction for questions Q1: Do they enjoy eating the dessert?, Q2: Do they like hiking in the desert?
Expected:False,
Got:True.
Wrong prediction for questions Q1: Why don’t we still do great music like in the 70’s and 80’s?, Q2: Should I raise my young child on 80’s music?
Expected:False,
Got:True.
3 tests passed
2 tests failed
this part of the code was already given by the grader,
Take the dot product to compute cos similarity of each pair of entries, v1, v2
25 # Since v1 and v2 are both vectors, use the function tf.math.reduce_sum instead of tf.linalg.matmul
—> 26 d = tf.math.reduce_sum(v1[j]*v2[j])
27 # Is d greater than the threshold?
28 res = d>threshold
so is my extract v1 and v2 from the model output code incorrect? I have recalled v1 and v2 using v1v2[0] for both, so I suppose recalling v2 also as v1 i.e. v1v2[0] is incorrect, can I get a hint!!! please
Regards
DP