查看 tf.data.Datasets 的文档,我看到经常提到“嵌套结构”。那到底是什么意思呢?任何 Python 数据类型都可以被视为嵌套结构(例如,(1,3, (7,6, (0), 5))
或 dict(k=dict(3), 7, 无
) 还是特指 TensorFlow 数据类型?
最佳答案
目前支持的结构类型有tuple
、dict
、namedtuple
。
来自 https://www.tensorflow.org/api_docs/python/tf/data/Dataset :
Common Terms: Element: A single output from calling next() on a dataset iterator. Elements may be nested structures containing multiple components. For example, the element (1, (3, "apple")) has one tuple nested in another tuple. The components are 1, 3, and "apple". Component: The leaf in the nested structure of an element.
Supported types: Elements can be nested structures of tuples, named tuples, and dictionaries. Element components can be of any type representable by tf.TypeSpec, including tf.Tensor, tf.data.Dataset, tf.SparseTensor, tf.RaggedTensor, and tf.TensorArray.
关于python - TensorFlow 中的嵌套结构是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59092423/