learn2branch icon indicating copy to clipboard operation
learn2branch copied to clipboard

How to deal with the "Converting sparse IndexedSlices to a dense Tensor of unknown shape." problem

Open ymabj opened this issue 4 years ago • 3 comments

Hi,

When I am running the codes in 03_train_gcnn.py there is a problem as following:

/root/miniconda3/envs/myenv/lib/python3.7/site-packages/tensorflow/python/ops/gradients_util.py:93: 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. "

I think this problem may happen due to the tf.gather() function you use in line 150.

        logits = model(batched_states)
        logits = tf.expand_dims(tf.gather(tf.squeeze(logits, 0), cands), 0)  # filter candidate variables
        logits = model.pad_output(logits, n_cands.numpy())  # apply padding now
        loss = tf.losses.sparse_softmax_cross_entropy(labels=actions, logits=logits)

I wonder if there is any substitute for tf.gather() to deal with this problem. Thank you.

ymabj avatar Oct 03 '19 14:10 ymabj

Hi,

I also encounter such a warning sometimes, although the code seems to run fine. I do not have much time to investigate the issue right now. If you find a workaround please let us know !

Best, Maxime

gasse avatar Oct 16 '19 18:10 gasse

It can also be the tf.gather in BipartiteGraphConvolution().

pg2455 avatar Dec 22 '19 02:12 pg2455

Hi there,

I also meet this warning. Could you please let me know if you have any suggestions about this issue?

Best, Mengyuan

mengyuan-lee avatar Apr 18 '20 19:04 mengyuan-lee