Skip to content

Mistake in Ch3. code #60

@ahussein1194

Description

@ahussein1194

In Chapter 3, in section Predicting with Multiple Inputs & Outputs code,

def vect_mat_mul(vect,matrix):
    assert(len(vect) == len(matrix)

the aim is to check that the number of inputs is equal to the number of weights for every output. But in fact len(matrix) corresponds to the number of outputs not number of weights. To check for the number of weights, we should write something like:

def vect_mat_mul(vect,matrix):
    assert(len(vect) == len(matrix[0])

for example

  • Also in the part of the code:
for i in range(len(vect)):
    output[i] = w_sum(vect,matrix[i])

it should be:

for i in range(len(matrix)):
    output[i] = w_sum(vect,matrix[i])

because we perform the weighted sum for each output, not for each input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions