The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

448325 (1) [Avatar] Offline
#1
This:

def w_sum(a,b):
    assert(len(a) == len(b))
    output = 0
    for i in range(a):
        output += (a[i] * b[i])
    return output


should be:

 for i in range(len(a)):


or we get an error :
'list' object cannot be interpreted as an integer



Also on page 32 the dot product of c = [ 0, 1, 1, 0] and e = [-1, 1, 0, 0] should be 1, not 0.
Clay Harris (1) [Avatar] Offline
#2
I was about to say the same thing. The following text needs to be updated as well, since it states that the -1 cancels out the positive, when really the calculation used is flawed
453435 (2) [Avatar] Offline
#3
Chapter 3 page 32
Small mistake on scalar value on dot product (weighted sum) example:

c = [ 0, 1, 1, 0]
e = [-1, 1, 0, 0]
print(np.dot(c,e))

is 1
in the book it is shown as 0
453435 (2) [Avatar] Offline
#4
Chapter 3 page 37
(3) Perform an Elementwise Multiplication

( 1.20 * 0.9 ) = 0.585 = sad prediction

This is not correct, it should be:

( 0.65 * 0.9 ) = 0.585 = sad prediction

180227 (1) [Avatar] Offline
#5
Problem in code page 39- --
def vect_mat_mul(vect,matrix):
assert(len(a) == len(b)) output = 0

a and b are not passed into the function. Code should use vect, matrix.

dmh2000 (4) [Avatar] Offline
#6
page 35
input = np.array([toes[0],wlrec[0],nfans[0]])
pred = neural_network(input,weight)
print(pred)

should be :
input = np.array([toes[0],wlrec[0],nfans[0]])
pred = neural_network(input,weights)
print(pred)
406316 (1) [Avatar] Offline
#7
Even correcting the code to
for i in range(len(a)):
doesn't work for me in the code on page 29, 32 as it just gives the product of the first elements of the two lists. I tried w_sum([3,1,5],[1,2,3]) which gave wrong result (6) whereas np.dot gave the correct answer (20). I hope that these errors are corrected so that readers actually get to the meat of things in deep learning. Any suggestions for the code?
360874 (4) [Avatar] Offline
#8
406316 wrote:Even correcting the code to
for i in range(len(a)):
doesn't work for me in the code on page 29, 32 as it just gives the product of the first elements of the two lists. I tried w_sum([3,1,5],[1,2,3]) which gave wrong result (6) whereas np.dot gave the correct answer (20). I hope that these errors are corrected so that readers actually get to the meat of things in deep learning. Any suggestions for the code?


Actually I do get 20 with the code below. If you had have reported that you got 3 I would have suggested that maybe you have the return statement as part of the for loop - in which case it would break out after one iteration and return 3, but to get 6 it would have had to break after 2 iterations! Hmmm...

def w_sum(a,b):    
    assert len(a) == len(b), "Number of Inputs does not equal number of Weights" 
    output = 0  
    for i in range(len(a)):    
        output += (a[i] * b[i])

    return output

print(w_sum([3,1,5],[1,2,3]))


# 20