Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

import tensorflow as tf 

import hyperchamber as hc 

 

from hypergan.losses.base_loss import BaseLoss 

 

class SoftmaxLoss(BaseLoss): 

 

def _create(self, d_real, d_fake): 

gan = self.gan 

config = self.config 

ops = self.gan.ops 

 

ln_zb = tf.reduce_sum(tf.exp(-d_real), axis=1)+tf.reduce_sum(tf.exp(-d_fake), axis=1) 

ln_zb = tf.log(ln_zb) 

 

d_loss = tf.reduce_mean(d_real, axis=1) + ln_zb 

g_loss = tf.reduce_mean(d_fake, axis=1) + tf.reduce_mean(d_real, axis=1) + ln_zb 

 

d_loss = ops.reshape(d_loss, []) 

g_loss = ops.reshape(g_loss, []) 

 

return [d_loss, g_loss]