【发布时间】:2019-01-19 20:28:11
【问题描述】:
我们使用不同的配置训练模型的许多变体,并且需要对输入进行不同的预处理(其中预处理在 TensorFlow 之外完成)。我想将我们的模型导出为 SavedModels,并且我认为我们将拥有一个 API 服务器,它将提供对模型的访问并处理预处理并使用配置与 TensorFlow 服务器对话,该配置将通过 TensorFlow 从模型元数据中检索服务器。模型元数据可能是结构化的 JSON,也可能使用协议缓冲区。我不清楚这方面的最佳实践是什么。特别是,MetaInfoDef 协议缓冲区具有三个不同的字段,它们似乎旨在保存元数据(meta_graph_version、any_info 和 tags)。但除了tags 字段外,我找不到任何使用的例子。
// User specified Version string. Can be the name of the model and revision,
// steps this model has been trained to, etc.
string meta_graph_version = 1;
[...]
// A serialized protobuf. Can be the time this meta graph is created, or
// modified, or name of the model.
google.protobuf.Any any_info = 3;
// User supplied tag(s) on the meta_graph and included graph_def.
//
// MetaGraphDefs should be tagged with their capabilities or use-cases.
// Examples: "train", "serve", "gpu", "tpu", etc.
// These tags enable loaders to access the MetaGraph(s) appropriate for a
// specific use-case or runtime environment.
repeated string tags = 4;
(虽然我不确定这三个字段是否都可以使用客户端 API 以相同的方式检索到 TensorFlow 服务?)
【问题讨论】:
-
我同意这个问题。查看
signature_def_utils.build_signature_defdocumentation 仅显示input、output和method的选项。也就是说,看起来没有人必须使用input选项进行输入。似乎任何东西都可以存储在那里,因为任何实际的键值对都必须单独提取以进行推理。这表明元数据可能会被存储和读取,而不用于推理。
标签: tensorflow tensorflow-serving