tensorflow / hub

A library for transfer learning by reusing parts of TensorFlow models.
https://tensorflow.org/hub
Apache License 2.0
3.47k stars 1.66k forks source link

TF hub in sagemaker #368

Closed rv-ltran closed 3 years ago

rv-ltran commented 5 years ago

How do I import tensorflow hub into AWS sagemaker? I'm looking to use this model https://tfhub.dev/google/universal-sentence-encoder/1

rmothukuru commented 5 years ago

@rv-ltran , Can you please let us know if you have tried importing TF Hub as mentioned in this link?

If you have tried executing the commands mentioned in the above link, is it resulting in error, and if so, can you please provide the error log.

rv-ltran commented 5 years ago
1 2 3 4

I have performed the following commands, and got the errors (attached):

!pip install "tensorflow_hub==0.4.0" !pip install "tf-nightly" import tensorflow as tf import tensorflow_hub as hub

rmothukuru commented 5 years ago

@rv-ltran, I ran your comments in a fresh virtual environment and I could successfully install and import Tensorflow and TF_Hub. Can you create a New Virtual Environment in Anaconda and execute those commands and let me know if your issue is resolved. Thanks!

rv-ltran commented 5 years ago

I opened a new notebook (conda-python3) within AWS Sagemaker , and ran these cmmds but still receiving the errors (attached). Did I follow your instruction correctly?

1 2 3

akhorlin commented 5 years ago

In general we haven't looked into sagemaker support yet but looking at the error message it seems there is an issue with importing tensorflow. Have you tried running a simple tensorflow program without tf hub to see if everything works properly?

rv-ltran commented 5 years ago

I switched to kernel conda-tensorflow and was able to import tensorflow. However, when I tried to import "https://tfhub.dev/google/universal-sentence-encoder/2", I ran into an error of RuntimeError: variable_scope module_3/ was unused but the corresponding name_scope was already taken.

Screen Shot 2019-09-23 at 9 58 54 AM
rv-ltran commented 5 years ago

Nvm, I removed tf.enable_eager_execution() cmmd and it works

arghyaganguly commented 3 years ago

Closing this based on the previous comment from @rv-ltran.Thanks.