-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from YeongHyeon/0.2.7
0.2.7
- Loading branch information
Showing
3 changed files
with
26 additions
and
12 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |