Load TensorFlow embedding model

Viewed 666

I am following the reference from the following page:

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

In the code the model is loaded from the internet with the following code:

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

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?

1 Answers

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

the code below works, assuming the unzipped embedding model .pb file and accompanying folders are located in the specified directory.

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