Python 如何将元组列表(tf.constant,tf.constant)转换为tensorflow数据集?

Python 如何将元组列表(tf.constant,tf.constant)转换为tensorflow数据集?,python,numpy,tensorflow,dataset,Python,Numpy,Tensorflow,Dataset,我试图创建一个转换器模型,我有两个np.Array,都有字符串,我用它们创建了一个元组列表 元组的格式为: class 'tuple' (tf.Tensor: shape=(), dtype=string, numpy=b'abc', tf.Tensor: shape=(), dtype=string, numpy=b'xyz') 我想将这些元组组合起来形成tensorflow.python.data.ops.dataset\u ops.\u options dataset,我该怎么做 或者我

我试图创建一个转换器模型,我有两个np.Array,都有字符串,我用它们创建了一个元组列表

元组的格式为:

class 'tuple' (tf.Tensor: shape=(), dtype=string, numpy=b'abc', tf.Tensor: shape=(), dtype=string, numpy=b'xyz')
我想将这些元组组合起来形成tensorflow.python.data.ops.dataset\u ops.\u options dataset,我该怎么做

或者我还有别的办法吗

新来的,谢谢你的帮助

您可以使用来自\u切片的张量\u

编辑


如果你能举个例子说明如何使用@U10转发,那就太好了。看到这个了吗
Example
# Two tensors can be combined into one Dataset object. 
values1 = tf.constant(['A', 'B', 'A']) # ==> 3x1 tensor
values2 = tf.constant(['A', 'B', 'A']) # ==> 3x1 tensor
dataset = Dataset.from_tensor_slices((values1, values2))