5

Using scatter_nd to project an attention distribution onto another distribution, essentially creating an distribution that references a vocabulary.

indices = tf.stack((batch_nums, encoder_batch), axis=2)
shape = [batch_size, vocab_size]
attn_dists_projected = [tf.scatter_nd(indices, copy_distribution, shape) for copy_distribution in attn_dists] 

When attempting to run this with placeholders with largely undefined dimensions, I ran into the following error:

ValueError: The inner 0 dimensions of output.shape=[?,?] must match the inner 1
dimensions of updates.shape=[128,128,?]: Shapes must be equal rank, but are 0 and 1
for 'final_distribution/ScatterNd' (op: 'ScatterNd') with input shapes: 
[128,?,2], [128,128,?], [2].

This in the context of seq2seq, so the model placeholders' shapes need to be partially undefined. Additionally, my data batches are not consistent in size, which necessitates variable batch sizes as well.

Arya Vohra
  • 71
  • 1
  • 2
    This is a good question, but can you distill this into a minimal test case that reproduces the error that people can run locally? If so it'll be easier to solve. – David Parks Mar 26 '18 at 16:12

0 Answers0