首页 > 解决方案 > 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。这个网站。

你碰巧知道解决方案吗?

标签: django

解决方案


推荐阅读