Skip to content

Commit

Permalink
Merge pull request #3 from YeongHyeon/0.2.7
Browse files Browse the repository at this point in the history
0.2.7
  • Loading branch information
YeongHyeon authored Feb 8, 2022
2 parents 22b4347 + 545fe78 commit 88ac281
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
Binary file added dist/whiteboxlayer-0.2.7-py3-none-any.whl
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name = 'whiteboxlayer',
version = '0.2.6',
version = '0.2.7',
description = 'TensorFlow based custom layers',
author = 'YeongHyeon Park',
author_email = '[email protected]',
Expand Down
36 changes: 25 additions & 11 deletions whiteboxlayer/extensions/losses.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
import tensorflow as tf

def loss_l1(x, reduce=None):
def loss_ae(x, reduce=None):

distance = tf.math.reduce_mean(\
loss = tf.math.reduce_mean(\
tf.math.abs(x), axis=reduce)

return distance
return loss

def loss_l2(x, reduce=None):
def loss_mse(x, reduce=None):

distance = tf.math.reduce_mean(\
loss = tf.math.reduce_mean(\
tf.math.square(x), axis=reduce)

return loss

def loss_rmse(x, reduce=None):

loss = tf.math.reduce_mean(\
tf.math.sqrt(\
tf.math.square(x) + 1e-30), axis=reduce)

return distance
return loss

def loss_l2_log(x, reduce=None):
def loss_log_mse(x, reduce=None):

distance = tf.math.reduce_mean(\
loss = tf.math.reduce_mean(\
-tf.math.log(\
1-tf.math.sqrt(\
tf.math.square(x) + 1e-30) + 1e-30), axis=reduce)
1 - tf.math.square(x) + 1e-30), axis=reduce)

return loss

def loss_bce(true, pred, reduce=None):

term1 = true * tf.math.log(pred + 1e-30)
term2 = (1 - true) * tf.math.log(1 - pred + 1e-30)
loss = tf.math.reduce_mean(-(term1 + term2), axis=reduce)

return distance
return loss

0 comments on commit 88ac281

Please sign in to comment.