bert icon indicating copy to clipboard operation
bert copied to clipboard

modeling/embedding_lookup function issue

Open futuresing opened this issue 2 years ago • 0 comments

To reshape the input, the code is:

if input_ids.shape.ndims == 2:
  input_ids = tf.expand_dims(input_ids, axis=[-1]

I'm wondering why we set axis = [-1] instead of -1 and how it is possible to pass a list to axis. I have tried this:

import tensorflow as tf 
t = tf.constant([1,2]) 
t1 = tf.expand_dims(t, axis=[0, 1]) 
print(t1.shape)

but it raised the error: 'dim' must be a tensor with a single value [Op:ExpandDims]

futuresing avatar Sep 03 '22 13:09 futuresing