【发布时间】:2019-08-03 00:05:41
【问题描述】:
当我读取带有下一个入口的 csv 文件时 2,3,"['动作','儿童']" 我想将第三个入口读取为带有两个字符串的张量,但是当我使用
tf.decode_csv('2,3,"['Action','Children']" ',[0,0,""])
当前结果是:
b"['Action','Children']"
我怎样才能得到结果:
tf.string ["Action","Children"] shape=(1,)
我想将其用作cathegorical_features。
【问题讨论】:
-
在tensorflow中可以使用
tf.compat.as_str_any将字节转为字符串 -
“Action”和“children”的存在暗示了(至少)两个特征。也许您可以澄清您是否尝试单独映射这些(因此每条记录都有 2 个新功能,一个用于操作,一个用于儿童)或者您是否尝试将其映射为“交叉功能” - 一个新列,但每个可能的值组合是您的分类特征的一个独特的可能类别
-
@Stewart 我想将张量
b"['Action','Children']"转换为张量[b'Action',b'Children'],因为我注意到第二个与tf.feature_column.categorical_column_with_vocabulary_list()配合得很好。
标签: python string list tensorflow categorical-data