How to use tensorflow hub in Azure ML

374 views Asked by At

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'
1

There are 1 answers

0
Ecstasy On BEST ANSWER

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

  • Try installing/upgrading the latest version of tensorflow and tensorflow-hub and then import:
!pip install --upgrade tensorflow

!pip install --upgrade tensorflow_hub

import tensorflow as tf

import tensorflow_hub as hub
  • Install the current environment as a new kernel:
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?