(tensor_BxL, updates_B, i)
return tf.tensor_scatter_nd_update(tensor_BxL, indices_Bx2, updates_B)
Inplace update a tensor. B: batch_size, L: tensor length.
Inplace update a tensor. B: batch_size, L: tensor length.
Inplace update a tensor . B : batch_size L : tensor length .
def inplace_update_i(tensor_BxL, updates_B, i):
  """Inplace update a tensor. B: batch_size, L: tensor length."""
  batch_size = tensor_BxL.shape[0]
  indices_Bx2 = tf.stack([
      tf.range(batch_size, dtype=tf.int64),
      tf.fill([batch_size], tf.cast(i, tf.int64))
  ],
                         axis=-1)
  return tf.tensor_scatter_nd_update(tensor_BxL, indices_Bx2, updates_B)
def inplace_update_i ( tensor_BxL , updates_B , i ) : batch_size = tensor_BxL . shape [ 0 ] indices_Bx2 = tf . stack ( [ tf . range ( batch_size , dtype = tf . int64 ) , tf . fill ( [ batch_size ] , tf . cast ( i , tf . int64 ) ) ] , axis = - 1 ) return tf . tensor_scatter_nd_update ( tensor_BxL , indices_Bx2 , updates_B )