Why do tf.zeros_like and tf.ones_like not return a tensor with all elements set to zero/one when passing a list of strings?
yiminglin-ai opened this issue · 0 comments
yiminglin-ai commented
Hi Chip,
The following snipet seems to quite confusing to me:
t_1 = [b"apple", b"peach", b"grape"] # 1-d arrays are treated like 1-d tensors
tf.zeros_like(t_1) # ==> [b'' b'' b'']
tf.ones_like(t_1) # ==> TypeError: Expected string, got 1 of type 'int' instead.
I understand that a list of strings is a 1-d array that is treated like 1-d tensors in Tensorflow, but I feel like tf.zeros_like(t_1) should return a tensor with a tensor of [0,0,0] since t_1 is of length 3? Also, I do not understand why ones_like and zeros_like treat t_1 differently?
Could you tell me tf.zeros_like and tf.ones_like are returning the results like above?
Thank you very much.