由于 () 形状无法拆分张量

Can't split tensor due to () shape

如果我打印 tensor.shape 我得到这个:

tf.Tensor(b["Can we make this quick?  Roxanne Korrine and Andrew Barrett are having an incredibly horrendous public break- up on the quad.  Again.",
"Well, I thought we'd start with pronunciation, if that's okay with you.",
'Not the hacking and gagging and spitting part.  Please.',
"Okay... then how 'bout we try out some French cuisine.  Saturday?  Night?"], 
shape=(), dtype=string)

为什么我的形状是 ()?我想将每个短语拆分为 2 个张量:

但是我不能使用split,因为我的张量形状是()。我试图用 set_shape(1, ) 改变它的形状,但我得到这个:

ValueError: Tensor's shape () is not compatible with supplied shape [1, None]

好吧,这是设计用于处理多维(数组中的数组)的常见张量,但看起来您有一个围绕单个字符串的单个数组。

就做正常的字符串处理

split_str = my_str.split('\n')