3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

TensorFlow Hub の SavedModel file does not exist

Posted at

TensorFlow Hubを使用したPythonスクリプトを実行した際に発生したエラーの対応備忘です。

発生したエラー

OSError: SavedModel file does not exist at: xxxx

発生タイミング

  1. TensorFlow Hubを使用したスクリプトを作成。当日は処理が正常終了しました。
  2. 数日後に上記と同じスクリプトを実行した際にエラー発生。

一次対応

エラー文言では指定フォルダにモデルが無いと言われています。
そこで、発生したエラー 記載の[XXXX]フォルダを削除後、再実行すると正常終了します。
フォルダ名の例:9c2e20adec1bcc53f52a607443d72850fcb108e3

原因

初回実行時にTensorFlow Hubモデルが一時フォルダに退避されます。
次回以降の実行の際に同フォルダを参照しますがモデル自体(.pbと.pbtxt)は存在しないためエラーとなります。

根本対応

以下のようにDLしたモデルのパスをhub.load()の引数に設定するようにするとエラーが発生せず、定期的に実行できるようになります。

model = hub.load("/Users/user_name/Model/universal-sentence-encoder-multilingual-large_3/")

継続的に利用する予定のモデルであればローカルなり、所定の場所に退避して使うのが賢いようです。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?