Модель TF в Google AI Platform Models Ошибка: «Ожидается, что сериализована как скаляр или вектор, получена форма: [1,12]» - PullRequest
0 голосов
/ 29 мая 2020

Как часть выходных данных tfx trainer и pusher, сохраненная модель / предварительно обученная модель была выполнена в заданиях и моделях платформы Google AI через следующие библиотеки.

from tfx.extensions.google_cloud_ai_platform.pusher import executor as ai_platform_pusher_executor
from tfx.extensions.google_cloud_ai_platform.trainer import executor as ai_platform_trainer_executor

Однако, когда я тестирую обслуживаемую модель в Google AI Platform Models, я получил следующее сообщение об ошибке. Не могли бы вы помочь мне понять, что это означает? Как мне преобразовать мои входные данные, чтобы они были приняты моделью?

Ошибка:

{
  "error": "Prediction failed: Error during model execution: <_MultiThreadedRendezvous of RPC that terminated with:\n\tstatus = StatusCode.INVALID_ARGUMENT\n\tdetails = \"Expected serialized to be a scalar or vector, got shape: [1,12]\n\t [[{{node ParseExample/ParseExampleV2}}]]\"\n\tdebug_error_string = \"{\"created\":\"@1590723484.491366234\",\"description\":\"Error received from peer ipv4:127.0.0.1:8081\",\"file\":\"src/core/lib/surface/call.cc\",\"file_line\":1056,\"grpc_message\":\"Expected serialized to be a scalar or vector, got shape: [1,12]\\n\\t [[{{node ParseExample/ParseExampleV2}}]]\",\"grpc_status\":3}\"\n>"
}

Пример ввода в модели платформы Google AI:

{
  "instances": [
["A", "B", "C", "D","E", "F", "G", "H", "I", "J", "K", "L"]
  ]
}

Вот код для инструкторов .

def get_model(show_summary=True):

#one-hot categorical features
num_A = 4
num_B = 3
num_C = 2
num_D = 8
num_E = 12
num_F = 4
num_G = 16
num_H = 26
num_I = 11
num_J = 2
num_K = 11
num_L = 2

input_A = tf.keras.Input(shape=(num_A,), name="A_xf")
input_B = tf.keras.Input(shape=(num_B,), name="B_xf")
input_C = tf.keras.Input(shape=(num_C,), name="C_xf")
input_D = tf.keras.Input(shape=(num_D,), name="D_xf")
input_E = tf.keras.Input(shape=(num_E,), name="E_xf")
input_F = tf.keras.Input(shape=(num_F,), name="F_xf")
input_G = tf.keras.Input(shape=(num_G,), name="G_xf")
input_H = tf.keras.Input(shape=(num_H,), name="H_xf")
input_I = tf.keras.Input(shape=(num_I,), name="I_xf")
input_J = tf.keras.Input(shape=(num_J,), name="J_xf")
input_K = tf.keras.Input(shape=(num_K,), name="K_xf")
input_L = tf.keras.Input(shape=(num_L,), name="L_xf")

inputs_con = tf.keras.layers.concatenate([
input_A,
input_B,
input_C,
input_D,
input_E,
input_F,
input_G,
input_H
input_I,
input_J,
input_K,
input_L])

dense_1 = tf.keras.layers.Dense(50, activation = 'relu')(inputs_con)
dense_2 = tf keras.layers.Dense(25, activation = "rely") (dense_1)
output = tf.keras.laters.Dense(1, activation = "sigmoid") (dense_2)
model = keras.Model(inputs=inputs, outputs=outputs)

_inputs = [
input_A,
input_B,
input_C,
input_D,
input_E,
input_F,
input_G,
input_H,
input_I,
input_J,
input_K,
input_L]

model = tf.keras.models.Model(_inputs, output)

model.compile(optimizer='rmsprop',
          loss='binary_crossentropy',
          metrics=['accuracy'])

if show_summary:
    model.summary()

return model
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...