1

I'm am getting this error just in the being of importing my packages. I haven't been able to find the correct remedy to fix the issue. Any help is greatly appreciated.

From what I can tell it looks to maybe be a Tensorflow issue?

from sklearn.model_selection import train_test_split
import pandas as pd
import tensorflow as tf
import tensorflow_hub as hub
from datetime import datetime

import bert
from bert import run_classifier
from bert import optimization
from bert import tokenization
Sam Russo
  • 31
  • 1
  • 6

2 Answers2

1

found this

Background Colab has two versions of TensorFlow pre-installed: a 2.x version and a 1.x version. Colab uses TensorFlow 2.x by default, though you can switch to 1.x by the method shown below.

Specifying the TensorFlow version Running import tensorflow will import the default version (currently 2.x). You can use 1.x by running a cell with the tensorflow_version magic before you run import tensorflow.

[ ] %tensorflow_version 1.x TensorFlow 1.x selected.

more detail : https://colab.research.google.com/notebooks/tensorflow_version.ipynb#scrollTo=NeWVBhf1VxlH

Zayeed
  • 11
  • 1
0

You seem to have TensorFlow 2.x while the bert module uses TensorFlow 1.x. You can verify here that Tensorflow 1.x has the tf.train.Optimizer module while according to this, Tensorflow 2.x has no such module.

Make sure you install the Tensorflow version that bert requires

Bashir Kazimi
  • 1,337
  • 1
  • 8
  • 8
  • Great, that's what I was seeing as well. Do you know how I can install the correct version? I currently have 2.1. Can I do it through pip install? – Sam Russo Mar 24 '20 at 18:58
  • Yes, you can use pip. To install tensorflow 1.15 for example, you could type: `pip install tensorflow==1.15` – Bashir Kazimi Mar 24 '20 at 19:29
  • I have the same issue. My versions are `tensorflow==1.15`, `bert-tensorflow==1.0.1`, `tensorflow-hub==0.8.0'. However, I still get the same error. Could please be able to let me know the reason. Thanks – Alain Michael Janith Schroter Apr 12 '20 at 01:31