Я использую tf.estimator для обучения и обслуживания модели тензорного потока.Обучение завершено, как и ожидалось, но не проходит.Я читаю свои данные как TFRecordDataset.Моя функция разбора применяет преобразование к функции "x2".«x2» - строка, которая разделена.преобразованная функция - "x3".
def parse_function(example_proto):
features={"x1":tf.FixedLenFeature((), tf.string), "x2":tf.FixedLenFeature((),
tf.string),
"label":tf.FixedLenFeature((), tf.int64)}
parsed_features = tf.parse_example(example_proto, features)
x3=tf.string_split(parsed_features["string"],',')
parsed_features["x3"]=x3
return parsed_features, parsed_features["label"]
Моя функция обслуживания -
def serving_input_fn():
receiver_tensor = {}
for feature_name in record_columns:
if feature_name in {"x1", "x2","x3"}:
dtype = tf.string
else:
dtype=tf.int32
receiver_tensor[feature_name] = tf.placeholder(dtype, shape=[None])
features = {
key: tf.expand_dims(tensor, -1)
for key, tensor in receiver_tensor.items()
}
return tf.estimator.export.ServingInputReceiver(features, receiver_tensor)
В прошлом она всегда работала, когда в моей функции синтаксического анализа не было никаких преобразований, нотеперь происходит ошибка с ошибкой.
cloud.ml.prediction.prediction_utils.PredictionError: Failed to run the provided model: Exception during running the graph: Cannot feed value of shape (2, 1) for Tensor u'Placeholder_2:0', which has shape '(?,)' (Error code: 2)
Я думаю, что мне нужно применить преобразование к "x2" в моей функции обслуживания, но я не знаю как.Любая помощь будет принята с благодарностью