Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch boolean_mask to dynamic_partition #2

Open
beangoben opened this issue Feb 2, 2018 · 1 comment
Open

Switch boolean_mask to dynamic_partition #2

beangoben opened this issue Feb 2, 2018 · 1 comment

Comments

@beangoben
Copy link

beangoben commented Feb 2, 2018

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]
@aquastar
Copy link
Member

aquastar commented Feb 5, 2018

thanks for your advice, will have a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants