Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 67a1de7

Browse files
rewrite the logistic regression cost function
1 parent 4461953 commit 67a1de7

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)

AltStyle によって変換されたページ (->オリジナル) /