I’m facing issue with given code:
UNQ_C20 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
You do not have to input any code in this cell, but it is relevant to grading, so please do not change anything
planes = planes_l[0] # get one ‘universe’ of planes to test the function
tmp_hash_table, tmp_id_table = make_hash_table(document_vecs, planes)
print(f"The hash table at key 0 has {len(tmp_hash_table[0])} document vectors")
print(f"The id table at key 0 has {len(tmp_id_table[0])} document indices")
print(f"The first 5 document indices stored at key 0 of id table are {tmp_id_table[0][0:5]}")
Error encountered for this code is given below:
IndexError Traceback (most recent call last)
in
2 # You do not have to input any code in this cell, but it is relevant to grading, so please do not change anything
3 planes = planes_l[0] # get one ‘universe’ of planes to test the function
----> 4 tmp_hash_table, tmp_id_table = make_hash_table(document_vecs, planes)
5
6 print(f"The hash table at key 0 has {len(tmp_hash_table[0])} document vectors")
in make_hash_table(vecs, planes, hash_value_of_vector)
37 for i, v in enumerate(vecs):
38 # calculate the hash value for the vector
—> 39 h = hash_value_of_vector(v, planes)
40
41 # store the vector into hash_table at key h,
in hash_value_of_vector(v, planes)
26 for i in range(n_planes):
27 # increment the hash value by 2^i * h_i
—> 28 hash_value += 2**i * h[0, i]
29
30 ### END CODE HERE ###
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed