shenweichen / DeepMatch

A deep matching model library for recommendations & advertising. It's easy to train models and to export representation vectors which can be used for ANN search.
https://deepmatch.readthedocs.io/en/latest/
Apache License 2.0
2.19k stars 525 forks source link

youtubednn部署报错 #82

Open kinghuin opened 2 years ago

kinghuin commented 2 years ago

Describe the bug(问题描述) hi,这是一个很棒的项目,我在 youtubednn user tower 部署完成后,报错

(Pdb) stub.Predict(request)
*** grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "ConcatOp : Expected concatenating dimensions in the range [-2, 2), but got 2
         [[{{node model_1/concatenate/concat}}]]"
        debug_error_string = "{"created":"@165693","description":"Error received from peer ipv4:*******:80**","file":"src/core/lib/surface/call.cc","file_line":952,"grpc_message":"ConcatOp : Expected concatenating dimensions in the range [-2, 2), but got 2\n\t [[{{node model_1/concatenate/concat}}]]","grpc_status":3}"

期待项目能够完善一下模型部署部分

To Reproduce(复现步骤) Steps to reproduce the behavior:

  1. 参考https://github.com/shenweichen/DeepMatch/issues/46#issuecomment-1038597409 修复deepctr的模型导出bug
  2. 参考https://github.com/shenweichen/DeepMatch/blob/v0.2.1/examples/run_youtubednn.py#L81 划出用户塔
  3. 如果使用tf.keras.models.save_model(user_embedding_model,"./export_model/youtubeuser/1") 则在导出阶段就报错
    TypeError: Could not build a TypeSpec for <KerasTensor: shape=(None, 15) dtype=float32 (created by layer 'tf.compat.v1.squeeze')> with type KerasTensor

    如果使用tf.saved_model.save(obj=user_embedding_model, export_dir='./export_model/youtube_dnn_user_tower/1',signatures=None) 则顺利导出,但在部署好以后,报错

    (Pdb) stub.Predict(request)
    *** grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "ConcatOp : Expected concatenating dimensions in the range [-2, 2), but got 2
         [[{{node model_1/concatenate/concat}}]]"
        debug_error_string = "{"created":"@165693","description":"Error received from peer ipv4:*******:80**","file":"src/core/lib/surface/call.cc","file_line":952,"grpc_message":"ConcatOp : Expected concatenating dimensions in the range [-2, 2), but got 2\n\t [[{{node model_1/concatenate/concat}}]]","grpc_status":3}"

    怀疑是建模时使用了一些不适合部署的操作

Operating environment(运行环境):

Additional context Add any other context about the problem here.