Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load TensorFlow embedding model

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?

like image 339
Mustard Tiger Avatar asked Jan 23 '26 21:01

Mustard Tiger


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\')
like image 178
Mustard Tiger Avatar answered Jan 25 '26 10:01

Mustard Tiger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!