2024-09-30 16:33:05 发布
网友
当我读到下一个入口的csv文件时 2,3,“[‘Action’,‘Children’]” 我想把第三个entrace读成带两个弦的张量,但是当我用
tf.decode_csv('2,3,"['Action','Children']" ',[0,0,""])
目前的结果是:
b"['Action','Children']"
我如何得到结果:
tf.string ["Action","Children"] shape=(1,)
我想把它用作cathegorical_features
cathegorical_features
我决定这样做:
CSV_COLUMNS=["Int1","Int2","genre"] DEFAULTS=[0,0,["Unknown"]] columns = tf.decode_csv('2,3,"['Action','Children']" ', record_defaults=DEFAULTS) features = dict(zip(CSV_COLUMNS, columns)) features["genre"]=tf.regex_replace(features["genre"],pattern="\[",rewrite="") features["genre"]=tf.regex_replace(features["genre"],pattern="\]",rewrite="") features["genre"]=tf.regex_replace(features["genre"],pattern="\'",rewrite="") features["genre"]=tf.strings.split(features["genre"],sep=",",result_type="RaggedTensor")
我决定这样做:
相关问题 更多 >
编程相关推荐