简体   繁体   English

在谷歌云中执行谷歌云 function 时出错,但在本地工作正常

[英]Error executing google cloud function in google cloud, but working fine in local

I am trying to do sentiment analysis using tensorflow JS using a google cloud function. When I am executing it in my local, everything is working as expected, but when deploying it to google cloud I am getting the below error.我正在尝试使用 tensorflow JS 使用谷歌云 function 进行情绪分析。当我在本地执行它时,一切都按预期工作,但是当将它部署到谷歌云时,我收到以下错误。

{"error":"Something went wrong. Please try again later.Error: GatherV2: the index value 32599 is not in [0, 19999]"}

First, "fetch" was a problem, I installed node-fetch and now fetch error is gone but still the function is responding with 500.首先,“fetch”是个问题,我安装了 node-fetch,现在 fetch 错误消失了,但 function 仍然以 500 响应。

My git repo, README has the instructions: https://github.com/arupsarkar/Retail-Demo-Cloud-Function我的 git repo,README 有说明: https://github.com/arupsarkar/Retail-Demo-Cloud-Function

Thank you,谢谢,

Alright, I figured out the error.好吧,我发现了错误。 I had to update the return object to a JSON or it could have been a string as well.我必须将返回值 object 更新为 JSON,否则它也可能是一个字符串。 You can see the changes in my github repo, however here is the change您可以在我的 github 存储库中看到更改,但这里是更改

  res.status(200).send(`{"score": ${score}}`);

Everything working as expected, initially I had for reference (see below) which was causing the error.一切都按预期工作,最初我有参考(见下文)导致错误。

  res.status(200).send(score);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM