python - 什么是 DT_VARIANT 张量?
问题描述
的构造函数tf.data.Dataset
接受一个参数variant_tensor
,该参数仅记录为:
代表数据集的 DT_VARIANT 张量。
和
在 DatasetV2 中,我们期望子类创建一个 variant_tensor 并将其传递给 super() 调用。
我在哪里可以了解“DT_VARIANT 张量”或“variant_tensor”是什么?
解决方案
变体张量可以是任何数据类型的张量。
变体张量的一些示例如下所示:
# Integer element
a = 1
# Float element
b = 2.0
# Tuple element with 2 components
c = (1, 2)
# Dict element with 3 components
d = {"a": (2, 2), "b": 3}
# Element containing a dataset
e = tf.data.Dataset.from_element(10)
关于Variant Tensor
或DT_Variant
的说明如下所示。
// This is an implementation of a type-erased container that can store an
// object of any type. The implementation is very similar to std::any, but has
// restrictions on the types of objects that can be stored, and eschews some of
// the fancier constructors available for std::any. An object of
// tensorflow::Variant is intended to be used as the value that will be stored
// in a tensorflow::Tensor object when its type is DT_VARIANT.
//
// tensorflow::Variant can store an object of a class that satisfies the
// following constraints:
//
// * The class is CopyConstructible.
// * The class has a default constructor.
// * It's either a protocol buffer, a tensorflow::Tensor, or defines the
// following functions:
//
// string TypeName() const;
// void Encode(VariantTensorData* data) const;
// bool Decode(VariantTensorData data);
更多详情请参考TF Org Page和Github 源代码。
推荐阅读
- javascript - 我删除时没有弹出我的吐司通知?
- python - drive api:列出垃圾箱中的文件
- apache-spark - 在 Amazon S3 中保持 Spark 作业的中间状态
- excel - 如何在excel中获取文件名的短版本直到第二个下划线
- javascript - 样式为按钮的单选按钮 - 'Enter' 按键行为
- azure-traffic-manager - Azure 流量管理器连接到专用终结点(内部入口)
- java - DigitalPersona U.are.U java SDK 在没有 GUI 的情况下无法回答
- python - 烧瓶不显示电子邮件/密码的值
- angular - Angular mat-navigation - 删除每页下拉项目周围的蓝色光芒
- python - 如何不在循环中重复自己 python