Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tflearn with tensorflow 2.0

I can't import tflearn with TensorFlow 2.0

Python 3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> import tflearn
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/summarizer.py", line 9, in <module>
    merge_summary = tf.summary.merge
AttributeError: module 'tensorboard.summary._tf.summary' has no attribute 'merge'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import tflearn
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/__init__.py", line 8, in <module>
    from . import models
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/models/__init__.py", line 2, in <module>
    from .dnn import DNN
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/models/dnn.py", line 6, in <module>
    from ..helpers.trainer import Trainer
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/__init__.py", line 2, in <module>
    from .evaluator import Evaluator
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/evaluator.py", line 9, in <module>
    from .trainer import evaluate_flow
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/trainer.py", line 20, in <module>
    from .summarizer import summaries, summarize, summarize_gradients, \
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tflearn/helpers/summarizer.py", line 12, in <module>
    merge_summary = tf.merge_summary
AttributeError: module 'tensorflow' has no attribute 'merge_summary'

Can anyone help me with this? I really need it to get solved as soon as possible. I am pretty much new to tensorflow.

like image 651
Ajay Dyavathi Avatar asked Oct 12 '19 18:10

Ajay Dyavathi


1 Answers

As of today, tflearn (v0.3.2) is not TensorFlow 2.0 ready, and specifically requires TF 1.x. I'm sure it will get updated at some point but for now, if you need tflearn, use TF 1.


I get a different error: ModuleNotFoundError: No module named 'tensorflow.contrib' since contrib has been moved to tensorflow_addons, and the pypi package is currently for Linux only.


Dec '20 update: v0.5.0 (released Nov '20) supports TF2, exclusively.

Note: Latest TFLearn (v0.5) is only compatible with TensorFlow v2.0 and over.

And make sure to import it correctly:

import tflearn
import tensorflow.compat.v1 as tf
like image 83
aneroid Avatar answered Sep 29 '22 19:09

aneroid