Hello.
In vect_mat_mul function in pg.41 of MEAP 11:
def vect_mat_mul(vect,matrix):
assert(len(vect) == len(matrix))
output = [0,0,0]
for i in range(len(vect)):
output[i] = w_sum(vect,matrix[i])
return output
assert is comparing the length of the vector to the length of the matrix which actually is the number of the rows in the matrix. However, because the row in the matrix represents each prediction, shouldn't the length of inputs, the vector, be compared to the length of the weights per prediction, the number of the columns in the matrix, instead, something like the below?
def vect_mat_mul(vect,matrix):
assert(len(vect) == len(matrix[0]))
output = [0,0,0]
for i in range(len(vect)):
output[i] = w_sum(vect,matrix[i])
return output
To me, it's like multiplying a 3 x 3 matrix to a 3 x 1 column vector, so comparing the number of the rows in the matrix to the number of rows in the column vector doesn't seem right. The number of columns in a matrix should match with the number of rows in a column vector to successfully multiply them together.
