Skip to content

Commit 16355ba

Browse files
committed
modify the function binary_cross_entropy in cost package
1 parent acb2175 commit 16355ba

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tensorlayer/cost.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ def binary_cross_entropy(output, target, epsilon=1e-8, name='bce_loss'):
7272
# output = ops.convert_to_tensor(output, name="preds")
7373
# target = ops.convert_to_tensor(targets, name="target")
7474
with tf.name_scope(name):
75-
return tf.reduce_mean(-(target * tf.log(output + epsilon) +
76-
(1. - target) * tf.log(1. - output + epsilon)))
75+
return tf.reduce_mean(tf.reduce_sum(-(target * tf.log(output + epsilon) +
76+
(1. - target) * tf.log(1. - output + epsilon)), axis=1))
7777

7878

7979
def mean_squared_error(output, target, is_mean=False):

0 commit comments

Comments
 (0)