简体   繁体   English

加载 TensorFlow 嵌入 model

[英]Load TensorFlow embedding model

I am following the reference from the following page:我正在关注以下页面的参考:

https://tfhub.dev/google/universal-sentence-encoder/4 https://tfhub.dev/google/universal-sentence-encoder/4

In the code the model is loaded from the internet with the following code:在代码中,model 是从 Internet 加载的,代码如下:

import tensorflow as tf

embed = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")

I would like to be able to load a model I have saved in my local directory我希望能够加载我保存在本地目录中的 model

For example:例如:

embed = hub.Module('data\models\universal-sentence-encoder_4.tar.gz')

This code returns the following error此代码返回以下错误

RuntimeError: Missing implementation that supports: loader

How can this be done?如何才能做到这一点?

The Issue was that the file was not unzipped.问题是该文件未解压缩。

After unzipping, the directory path was pointed to the unzip content location, with no file name specified.解压后,目录路径指向解压内容位置,没有指定文件名。

Also the Module method was changed to load Module方法也更改为load

the code below works, assuming the unzipped embedding model.pb file and accompanying folders are located in the specified directory.下面的代码有效,假设解压缩的嵌入 model.pb 文件和随附的文件夹位于指定目录中。

embed = hub.load('data\models\')

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

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