Recently I met the same issue, and I fix it with a little trick (maybe someone has same problem, even though this post has been published almost 1 year).
Firstly, TensorFlow cannot convert this array into a dense tensor, so I concat the array into string list, likes a = ['2','1,2,3','4,5']
Then split this string by using pure TF code, here is simple code:
def pad_length(sequence, limited_len):
seq_sparse = tf.string_split(sequence, ',')
seq_dense = tf.sparse_to_dense(
seq_sparse.indices, seq_sparse.dense_shape, tf.cast(tf.string_to_number(seq_sparse.values), tf.int32)
)
seq_slice = tf.strided_slice(seq_dense, [0, 0], [tf.shape(sequence)[0], limited_len])
pad_dense = tf.pad(seq_slice, paddings=[[0, 0], [0, limited_len - tf.shape(seq_slice)[1]]])
return pad_dense
a = ['2','1,2,3','4,5']
a = tf.convert_to_tensor(a)
b = pad_length(a, 3)
sess=tf.Ssssion()
sess.run(b)
"""
b => array([
[2, 0, 0],
[1, 2, 3],
[4, 5, 0]
], dtype=int32)
"""
Cheers!