django - nlp 模型和 django 标记器未链接
问题描述
在 colab 中创建 NLP 模型后,我将其下载为 h5 文件。我将文件粘贴到 django。只有 h5 文件。但是经过 tokenizer.text_to_sequences 之后,所有的值都变成了 null。有什么问题?
在 django 中实现的代码是
def result(request):
full = request.GET['fulltext']
full = okt.morphs(full, stem=True)
full = [word for word in full if not word in stopwords]
encoded = tokenizer.texts_to_sequences([full])
# error !!!!
pad_new = pad_sequences(encoded, maxlen=80)
score = float(model.predict(pad_new))
return render(request, 'testapp/result.html', {'score': score})
Encoded = tokenizer.texts_to_sequences ([full]) - 除了这部分,它运行良好。
分词器。我认为这里的数据是空的。
代码是https://wikidocs.net/44249。这个网站。
你碰巧知道解决方案吗?
解决方案
推荐阅读
- html - 我的 MetaTag 没有在任何地方更新,这是怎么回事?
- c++ - WxWidgets:wxQueueEvent 导致分段错误
- python - ValueError:使用带有 Chunksize 和 lines=True 的 Pandas 读取 JSON 时预期的对象或值
- node.js - 使用 express 包装现有 API 的最佳实践(本例中为 WordPress API)
- typescript - Typescript:结构类型检查具有不一致的行为
- tendermint - 如何将修改后的tendermint代码集成到超级账本洞穴中
- c# - 如何使用我自己的自定义设计自定义招摇 UI
- angular - 如何使用 Angular 在 Ionic 中创建成功的天气 api 获取请求?
- python - 用一定数量的值填充空 df - Python
- r - R:“输入中没有可用的行”从目录中读取多个 csv 文件时出错