2

I was following this tutorial and ran across an issue while using train.py. the issue says

Exception has occurred: ModuleNotFoundError
No module named 'tensorflow.contrib'
  File "F:\PythonFiles\Post Generator\gpt-2\src\model.py", line 3, in <module>
    from tensorflow.contrib.training import HParams

I searched a lot on the internet and it turns out that tensorflow.contrib has been depreceated. So is there an alternate way to do so or the gpt-2 is not usable with python?

I also tried

pip install tensorflow==1.15

ERROR: Could not find a version that satisfies the requirement tensorflow==1.15 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0)
ERROR: No matching distribution found for tensorflow==1.15
Guy Coder
  • 24,501
  • 8
  • 71
  • 136
  • `tensorflow.contrib` is deprecated in Tensorflow 2.x. So, I think `pip install tensorflow==1.15` should fix the problem. I don't know how it returns an Error with you. Could you tell me the result of `pip install tensorflow==`, please? – Anwarvic Jun 13 '20 at 16:35
  • You need to update your pip version... use `pip install -U pip` – Anwarvic Jun 27 '20 at 09:37
  • Please see the answer here: https://stackoverflow.com/a/64547620/13105088 – idontknow Dec 11 '20 at 19:15

1 Answers1

0

try this :

pip install tensorflow-gpu==1.15.0
pip install 'tensorflow-estimator<1.15.0rc0,>=1.14.0rc0' --force-reinstall