pythonazuretensorflowtensorflow-hubazure-machine-learning-service

How to use tensorflow hub in Azure ML


I am trying to use TensorFlow Hub in Azure ML Studio

I am using the kernel Python 3.8 PT and TF

And I installed a few modules:

!pip install bert-for-tf2
!pip install sentencepiece
!pip install "tensorflow>=2.0.0"
!pip install --upgrade tensorflow-hub

With pip list, I can see they are installed:

tensorflow                              2.8.0
tensorflow-estimator                    2.3.0
tensorflow-gpu                          2.3.0
tensorflow-hub                          0.12.0
tensorflow-io-gcs-filesystem            0.24.0

However when I try to use it as per the documentation (https://www.tensorflow.org/hub)

Then I get the classic:

ModuleNotFoundError: No module named 'tensorflow_hub'

Solution

  • To resolve this ModuleNotFoundError: No module named 'tensorflow_hub' error, try following ways:

    !pip install --upgrade tensorflow
    
    !pip install --upgrade tensorflow_hub
    
    import tensorflow as tf
    
    import tensorflow_hub as hub
    
    python3 -m ipykernel install --user --name=testenvironment
    

    You can refer to ModuleNotFoundError: No module named 'tensorflow_hub', No module named 'tensorflow_hub' and How to use Tensorflow Hub Model?