Fusion-GAN icon indicating copy to clipboard operation
Fusion-GAN copied to clipboard

Switch boolean_mask to dynamic_partition

Open beangoben opened this issue 8 years ago • 1 comments

Hi as a suggestion when computing the WGAN loss in your descriminator. Newer versions of tensorflow will throw a warning an error at the usage of bolean_mask with sparse and shape changing tensors (for example when switching the batch size, fro a training/test set).

It is suggested to replace with dynamic_partition.

The warning will be:

UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. 
This may consume a large amount of memory.
"Converting sparse IndexedSlices to a dense Tensor of unknown shape. "

The original code is:

xy_neg = tf.boolean_mask(tf.transpose(self.scores), tf.cast(self.input_y[:, 0], tf.bool))
xy_pos = tf.boolean_mask(tf.transpose(self.scores), tf.cast(self.input_y[:, 1], tf.bool))

the change would look like this:

parts = tf.dynamic_partition(self.scores,  tf.cast(self.input_y[:, 1], tf.int32l), 2)
xy_neg = parts[0]
xy_pos = parts[1]

beangoben avatar Feb 02 '18 19:02 beangoben

thanks for your advice, will have a try

aquastar avatar Feb 05 '18 21:02 aquastar