W4 Assignment - hash_value_of_vector

I am struggling to figure out the following error. I understand the error is coming from incompatible dimensions of the vec and planes argument, but I don’t understand how to use planes with (20,8) when vec has a 300 dimension.

ValueError                                Traceback (most recent call last)
<ipython-input-48-cd00c4542d1b> in <module>
      1 # Test your function
----> 2 w4_unittest.test_hash_value_of_vector(hash_value_of_vector)

~/work/w4_unittest.py in test_hash_value_of_vector(target)
   4450 
   4451     for test_case in test_cases:
-> 4452         result = target(**test_case["input"])
   4453 
   4454         try:

<ipython-input-46-5054df5fbddd> in hash_value_of_vector(v, planes)
     16     print(vec.shape)
     17     print(planes.shape)
---> 18     dot_product = np.dot(vec, planes)
     19 
     20     # get the sign of the dot product (1,10) shaped vector

<__array_function__ internals> in dot(*args, **kwargs)

ValueError: shapes (1,300) and (20,8) not aligned: 300 (dim 1) != 20 (dim 0)

Hi @Megan_Robertson

Aren’t you using vec variable instead of v inside your function?

In order to answer the original confusion, you should take a look at instructions:

  • First multiply your vector v, with a corresponding plane. This will give you a vector of dimension (1, N_planes).

and your function’s docstring states:

Input:
    - v:  vector of tweet. It's dimension is (1, N_DIMS)
    - planes: matrix of dimension (N_DIMS, N_PLANES) - the set of planes that divide up the region

So, when you dot multiply (1, N_DIMS) with (N_DIMS, N_PLANES) you get (1, N_PLANES).