tensorflow服务请求错误,{第二个输入必须是标量,但形状为[1]}

问题描述

我是tensorflow服务的新手,这是我发布的数据:

data_0 = {'inputs/input_x': mfcc[0],"inputs/is_training":False,"inputs/keep_prob":1}

data = json.dumps({"signature_name":'serving_default','instances':[data_0]})

headers = {"Content-type": "application/json"}

json_response = requests.post(URL,data=data,headers=headers)

我从批量归一化的is_training标志中得到了一个错误(我认为辍学率也是一样):

{ "error": "The second input must be a scalar,but it has shape [1]\n\t [[{{node conv_layer2/conv2/batch_normalization/cond/Switch}}]]" }

然后我看到了类似的问题,并将代码修改为

data_0 = {'inputs/input_x': mfcc[0],"inputs/is_training":[False],"inputs/keep_prob":[1]}

然后我又有了一个维度:

{ "error": "The second input must be a scalar,but it has shape [1,1]\n\t [[{{node conv_layer2/conv2/batch_normalization/cond/Switch}}]]" }

我尝试过不带[]的帖子,例如:

data = json.dumps({"signature_name":'serving_default','instances':data_0})

我得到了:

"error": "JSON Value:{...}  Excepting \'instances\' to be an list/array" }

我的模特信息:

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

signature_def['serving_default']:
  The given SavedModel SignatureDef contains the following input(s):
    inputs['inputs/input_x'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1,34,20)
        name: inputs/input_x:0
    inputs['inputs/is_training'] tensor_info:
        dtype: DT_BOOL
        shape: unknown_rank
        name: inputs/is_training:0
    inputs['inputs/keep_prob'] tensor_info:
        dtype: DT_FLOAT
        shape: unknown_rank
        name: inputs/keep_prob:0
  The given SavedModel SignatureDef contains the following output(s):
    outputs['Softmax'] tensor_info:
        dtype: DT_FLOAT
        shape: (-1,2)
        name: Softmax:0
  Method name is: tensorflow/serving/predict

这里需要帮助,谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)