return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
TypeError: 'rock' has type str, but expected one of: bytes
解决方式:
转byte feature时用tf.compat.as_bytes(value)将字节或 Unicode 转换为 bytes,使用 UTF-8 编码文本:
def _bytes_feature(value):
value = tf.compat.as_bytes(value)#####
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
没有评论:
发表评论