【发布时间】:2019-09-17 05:34:41
【问题描述】:
在从邮递员调用 api 时出现 tensorflow 维度的错误,但是当我在没有 api 调用的情况下运行函数时运行完美。 例如:
我在烧瓶中制作了这个 api:
def main_function():
round2 =clean_text_round2(my_text)
round3 = str(Punctuation(round2))
-------
test = json.dumps(somejsonformat)
return test
我的 api 是
@app.route('/',methods=['POST','GET'])
def padd():
main_function()
app.run()
抛出此错误: 从邮递员调用 api 时出现 tensorflow 维度的错误,但是当我在没有 api 调用的情况下运行函数时运行完美。
但是, 当我不从函数返回 json 数据时 然后它给了我想要的结果。代码是 test = json.dumps(somejsonformat)
这个测试是 JSON 数据 当我通过 api 返回它时 像这样:
@app.route('/',methods=['POST','GET'])
def padd():
return test
app.run()
它为我提供以下 json 格式的数据:
array:22 [▼
"edates" => array:21 [▶]
"edate_tag" => array:21 [▶]
"locations" => array:12 [▶]
"location_tag" => array:12 [▶]
"emails" => array:2 [▼
0 => "Sameera.itops@gmail.com"
1 => "https://www.linkedin.com/in/sameera-cherukuri-888589150/"
]
"emails_tag" => array:2 [▶]
"cdates" => []
"cdates_tag" => []
]
但是当我返回 json 数据时出现上述错误(测试) 通过函数并通过api函数padd()调用它。
如果有人可以帮助我解决这个问题,那将是很大的帮助。
【问题讨论】:
-
Keras 模型在哪里?你在哪里使用模型?
-
它在api调用函数之外。eg: from keras.models import Model, Input from keras.layers.merge import add from keras.layers import LSTM, Embedding, Dense, TimeDistributed,
-
我不明白。在代码中的某处,您必须加载和使用模型,例如它的
predict函数。它在哪里?您是否加载预训练模型? api调用(padd())和模型有什么关系? -
我已经邮寄给你了...我在哪里可以分享我的完整代码,以便您获得更多...请您检查邮件
-
您可以使用 Github 存储库或 gist 公开您的代码。此外,最好编辑您的问题并在其中添加更多详细信息,以便其他遇到相同问题的人可以从中受益。
标签: python-3.x tensorflow flask keras deep-learning