问题描述
我有字符串标签,例如cat"、dog".我可以将字符串标签直接提供给 Tensorflow 中的深度学习模型并获得字符串标签作为预测吗?我正在寻找相当于 sklearn 的 labelEncoder sklearn.preprocessing import LabelEncoder
I have string labels such as "cat", "dog". Can I feed string labels directly to deep learning models in Tensorflow and get string labels as predictions? I am looking for the equivalent of sklearn's labelEncoder sklearn.preprocessing import LabelEncoder
如果这是不可能的,有没有办法将标签打包到savedModel protobuf文件中并在服务时间根据索引检索它们?我正在使用 Estimator 的 export_savedModel API.assets_extra 是正确的方法吗?https://github.com/tensorflow/serving/issues/55不使用 savedModel 格式.
If this is not possible, is there a way to pack the labels into savedModel protobuf file and retrieve them based on indices during serving time? I am using Estimator's export_savedModel API. Is assets_extra the right way? The one at https://github.com/tensorflow/serving/issues/55 does not use savedModel format.
推荐答案
在深度学习中处理标签数据的典型方法是将标签嵌入向量空间.语言模型通常使用 词嵌入来实现.TensorFlow 提供了嵌入查找操作,您可以用于您的目的.
The typical way to handle label data in deep learning is to embed the labels in a vector space. Language models do it routinely with word embedding. TensorFlow provides embedding lookup operations that you can use for you purposes.
这篇关于如何将字符串标签打包到savedModel中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!