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.

hettlage (136) [Avatar] Offline
#1
I have some questions regarding listing 4.5.

1. Why don't you use -y log( h ) - (1 – y) log( 1 – h ) as the cost function?

2. Shouldn't the minus sign be omitted in y_model = tf.sigmoid(-(w[1] * X + w[0])) ?

3. I tried using the code with all training x values shifted by 3. I would expect the code to find a w[0] close to -3, but that doesn't seem to be the case. Why?
Nishant Shukla (52) [Avatar] Offline
#2
Hi hettlage,

Thanks for these great questions!

1. You're right. I think this is a typo.

2. Yes, you're right. The sigmoid function already negates the value.

3. I bet it's because of the faulty cost function above

Thanks again for pointing out these mistakes! The next MEAP update will come with fixes!
455199 (2) [Avatar] Offline
#3
re 1: Same issue with cost function in listing 4.6 too.
re: 2: I guess it will compute the w values as negative of what you would get otherwise. The locally defined sigmoid function is also used with the same error, so the plot looks correct - the two errors cancel each other out smilie
weiju (9) [Avatar] Offline
#4
Hi, I see that the latest version of listing 4.5 removes the "-", but now the graph in figure 4.11 does not match anymore.
gli (4) [Avatar] Offline
#5
The same problem with cost function in listing 4.7