Ludwik Trammer (2) [Avatar] Offline

I really like the book, but I think there are some problems with chapter 3 code (if I'm not mistaken, which is also possible):

pred = neural_network(input,weight)
on pages 38 and 40 should be
pred = neural_network(input,weights)

2. It seems that function vect_mat_mul on page 39 has a body belonging to w_sum from an earlier example. This seems like a mistake, since the argument names are completely different (vect and matrix in the signature vs. a and b used in the body), beside that vect_mat_mul should return a list of predictions, while the code returns a single number.

3. vect_mat_mul on page 41 has a correct body, except for the line
assert(len(a) == len(b))
which seems like a leftover from the previous w_sum code - a and b are not even available variable names here.

4. On page 42 the line
weights = [ih_wgt, hp_wgt)
should probably read
weights = [ih_wgt, hp_wgt]

5. on page 44 there is a comment "# matrix with all numbers between 0 and 1" but the code it is supposed to describe seems to be missing (although its output seems to be displayed).
Scratch that. I just realised that the comment applies to the previous line. The formatting is a little confusing, but the code is correct.
Ludwik Trammer (2) [Avatar] Offline
On more thing I forgot to mention. This is maybe more nuanced, but I believe that in vect_mat_mul on page 41, instead of
for i in range(len(vect)):
it should read
for i in range(len(matrix)):

The loop should iterate through each row of the matrix (weights) (quote from the book: "This function iterates through each row of our weights (each row is a vector)") , but the actual code looks more like it is iterating through vectors (inputs). Granted, this code will work, but it is misleading and the only reason it works is that in this particular example there are equal numbers of inputs and outputs. If this wasn't the case the code would fail, which doesn't seem right.
3736 (1) [Avatar] Offline
FYI - These mistakes are still in V10 of the MEAP. (Dec 2017)
451454 (2) [Avatar] Offline
In addition to this at pages 29 and 32 the code

for i in range(a):

in python 3.x cannot compile because a is a list and range expects an integer so it should be:

for i in range(len(a)):

451454 (2) [Avatar] Offline
And @page 39 the entire body of the function vect_mat_mul is wrong because has been copied from the previous example.

@page 41 the vector "vector of zeros" should be defined, maybe:

output = [0]*len(vector)