hettlage (115) [Avatar] Offline
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
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
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
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
The same problem with cost function in listing 4.7