Error in C3_W2_RecSysNN_Assignment

I am facing an error in “5.2 - Predictions for an existing user” of the lab notebook.
it says
error in get_user_vecs, did not find uid in user_train


UnboundLocalError Traceback (most recent call last)
in
1 uid = 2
2 # form a set of user vectors. This is the same vector, transformed and repeated.
----> 3 user_vecs, y_vecs = get_user_vecs(uid, user_train_unscaled, item_vecs, user_to_genre)
4
5 # scale our user and item vectors

~/work/recsysNN_utils.py in get_user_vecs(user_id, user_train, item_vecs, user_to_genre)
138 print(“error in get_user_vecs, did not find uid in user_train”)
139 num_items = len(item_vecs)
→ 140 user_vecs = np.tile(user_vec, (num_items, 1))
141
142 y = np.zeros(num_items)

UnboundLocalError: local variable ‘user_vec’ referenced before assignment

1 Like

Just a first guess, did you modify anything in the cell in Section 5.1, which creates a new user?

It’s OK to change the ratings, but not the new_user_id. And I’m not exactly sure how the “new_rating_count” is used.

No I didn’t change any thing…

Update for those who find this thread in the future:

Be wary of hard-coding the number of output layer units.

1 Like

Thank you for your help…