我正在嘗試使用以下代碼對保存的模型進行預測 features = np.ones((20, 40, 3), dtype=np.float32) features = tf.convert_to_tensor(value, dtype=tf.float32) imported_model = tf.saved_model.load(export_dir=os.path.join(os.path.join(model_path, directory))) import_fn = imported_model.signatures["serving_default"] import_fn(features)使用Tensorflow 2運行時,我收到以下錯誤。當我使用saved_model_cli時,模型預測工作正常。tensorflow.python.framework.errors_impl.InvalidArgumentError: In[0] is not a matrix. Instead it has shape [20,40,3] [[node dense/BiasAdd (defined at model_manager.py:54) ]] [Op:__inference_pruned_318590]保存的 cli 命令如下所示saved_model_cli run --dir ./model_dir --tag_set serve --signature_def serving_default --input_exprs 'input=np.ones((20, 40, 3), dtype=np.float32)'
添加回答
舉報
0/150
提交
取消