Модель ошибки / att_seq2seq / Minimum: 0 загружается и выбирается - PullRequest
0 голосов
/ 27 февраля 2019

Я успешно экспортировал модель seq2seq в формате SavedModel со следующим кодом

  source_tokens_ph = tf.placeholder(dtype=tf.string, shape=(1, None))
  source_len_ph = tf.placeholder(dtype=tf.int32, shape=(1,))

  features_serve = {
    "source_tokens": source_tokens_ph,
    "source_len": source_len_ph
  }

  experiment = PatchedExperiment(
  ...

  export_strategies = [saved_model_export_utils.make_export_strategy(serving_input_fn = build_default_serving_input_fn(features_serve))]
  )

Сохраненный_модель_cli показывает, что в экспортированном файле * 1008 существуют следующие SignatureDefs*

MetaGraphDef with tag-set: 'serve' contains the following SignatureDefs:

signature_def['default_input_alternative:default_output_alternative']:
The given SavedModel SignatureDef contains the following input(s):
inputs['source_ids'] tensor_info:
    dtype: DT_INT64
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_1_Lookup:0
inputs['source_len'] tensor_info:
    dtype: DT_INT32
    shape: (-1)
    name: model/att_seq2seq/Minimum:0
inputs['source_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/strided_slice:0
The given SavedModel SignatureDef contains the following output(s):
outputs['attention_context'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 512)
    name: model/att_seq2seq/transpose_4:0
outputs['attention_scores'] tensor_info:
    dtype: DT_FLOAT
    shape: unknown_rank
    name: model/att_seq2seq/transpose_2:0
outputs['cell_output'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 256)
    name: model/att_seq2seq/transpose_1:0
outputs['features.source_ids'] tensor_info:
    dtype: DT_INT64
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_1_Lookup:0
outputs['features.source_len'] tensor_info:
    dtype: DT_INT32
    shape: (-1)
    name: model/att_seq2seq/Minimum:0
outputs['features.source_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/strided_slice:0
outputs['logits'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 42)
    name: model/att_seq2seq/transpose:0
outputs['predicted_ids'] tensor_info:
    dtype: DT_INT32
    shape: (-1, -1)
    name: model/att_seq2seq/transpose_3:0
outputs['predicted_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_3_Lookup:0
Method name is: tensorflow/serving/predict

signature_def['serving_default']:
The given SavedModel SignatureDef contains the following input(s):
inputs['source_ids'] tensor_info:
    dtype: DT_INT64
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_1_Lookup:0
inputs['source_len'] tensor_info:
    dtype: DT_INT32
    shape: (-1)
    name: model/att_seq2seq/Minimum:0
inputs['source_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/strided_slice:0
The given SavedModel SignatureDef contains the following output(s):
outputs['attention_context'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 512)
    name: model/att_seq2seq/transpose_4:0
outputs['attention_scores'] tensor_info:
    dtype: DT_FLOAT
    shape: unknown_rank
    name: model/att_seq2seq/transpose_2:0
outputs['cell_output'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 256)
    name: model/att_seq2seq/transpose_1:0
outputs['features.source_ids'] tensor_info:
    dtype: DT_INT64
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_1_Lookup:0
outputs['features.source_len'] tensor_info:
    dtype: DT_INT32
    shape: (-1)
    name: model/att_seq2seq/Minimum:0
outputs['features.source_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/strided_slice:0
outputs['logits'] tensor_info:
    dtype: DT_FLOAT
    shape: (-1, -1, 42)
    name: model/att_seq2seq/transpose:0
outputs['predicted_ids'] tensor_info:
    dtype: DT_INT32
    shape: (-1, -1)
    name: model/att_seq2seq/transpose_3:0
outputs['predicted_tokens'] tensor_info:
    dtype: DT_STRING
    shape: (-1, -1)
    name: model/att_seq2seq/hash_table_3_Lookup:0
Method name is: tensorflow/serving/predict

Я подключил модель с помощью Tensorflow Serving и отправил следующий запрос,

{
    "inputs": {
        "source_tokens": "[['DATE','OF','BIRT']]",
        "source_ids": [],
        "source_len": [3]
    }
}

Однако он возвращает результат как

{"errormsgstr ":" model / att_seq2seq / Minimum: 0 загружается и выбирается. "}

При обращении к ошибке я мог видеть, что проблема может возникнуть из-за того, что один и тот же Tensor подается и извлекается .

Анализ показывает SignatureDef, model/att_seq2seq/Minimum:0 принадлежит как inputs['source_len'], так и outputs['features.source_len']

Как я могу решить эту проблему?Можно ли не получить outputs['features.source_len']?

Как вручную назначить SignatureDefs для экспериментального API, используемого в этом репо?

...