我对某些涉及字符串拆分的功能逻辑具有处理功能。
数据集中的有效张量:<tf.Tensor 'arg0:0' shape=(1,) dtype=string>
服务功能<tf.Tensor 'DecodeCSV:1' shape=(?, 1) dtype=string>
服务功能:
def csv_serving_input_fn():
csv_row = tf.placeholder(shape=[None], dtype=tf.string)
features = parse_csv(csv_row, is_serving=True)
...
return tf.estimator.export.ServingInputReceiver(
features=process_features(features),
receiver_tensors={'csv_row': csv_row}
)
解析函数
def parse_csv(csv_row, is_serving=False):
columns = tf.decode_csv(tf.expand_dims(csv_row, -1), record_defaults=HEADER_DEFAULTS)
return dict(zip(HEADER, columns))
形状(?,)失败
def process_features(features):
x = tf.string_split(features['text'])
....
错误:
ValueError: Shape must be rank 1 but is rank 2 for 'StringSplit' (op: 'StringSplit') with input shapes: [?,1], [].
正确的服务功能是什么?