Skip to content

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

Description

@ymabj

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions