forked from evigog/VocalSeparation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
24 lines (24 loc) · 629 Bytes
/
utils.py
File metadata and controls
24 lines (24 loc) · 629 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
+from constants import *
+import tensorflow as tf
+
+#define different loss functions
+#option1 mse
+#option2 KL distance
+#todo add discriminative objective for vocal + instrumental case
+def loss_function(option, output, batchY):
+
+ if (option == 1):
+ sub = tf.subtract(output, batchY)
+ loss = tf.sqrt(tf.abs(sub))
+ elif (option == 2):
+ loss = d_measure(batchY, output)
+
+ return loss
+
+#compute KL distance of input tensors
+def d_measure(A, B):
+ c1 = tf.multiply(A, tf.log(tf.div(A,B)) )
+ c2 = tf.subtract(B, A)
+ s = tf.summary(c1 + c2)
+
+ return s