Skip to content

Commit 812ae4f

Browse files
authored
Merge pull request #38 from ghost/patch-1
rewrite the logistic regression cost function
2 parents 719a871 + 67a1de7 commit 812ae4f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ch04_classification/logistic_2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def sigmoid(x):
2323
w = tf.Variable([0., 0., 0.], name="w", trainable=True)
2424

2525
y_model = tf.sigmoid(-(w[2] * X2 + w[1] * X1 + w[0]))
26-
cost = tf.reduce_mean(-tf.log(y_model * Y + (1 - y_model) * (1 - Y)))
26+
cost = tf.reduce_mean(-tf.log(y_model) * Y -tf.log(1 - y_model) * (1 - Y))
2727
train_op = tf.train.GradientDescentOptimizer(learning_rate).minimize(cost)
2828

2929
with tf.Session() as sess:

0 commit comments

Comments
 (0)