the-deep-learners / deep-learning-illustrated

Deep Learning Illustrated (2020)
https://www.deeplearningillustrated.com
MIT License
708 stars 355 forks source link

tflearn and tensorflow 2.0 #7

Open exAbstracto opened 4 years ago

exAbstracto commented 4 years ago

Hi Jon,

First of all, great book, thank you for putting it together! It's a great resource, easy to read and very well structured!

I noticed an issue with the alexnet_in_keras notebook. The error I get (on my mac but also with your version hosted on Google Colab) is:

"--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last)

in () ----> 1 import tflearn.datasets.oxflower17 as oxflower17 2 X, Y = oxflower17.load_data(one_hot=True) 2 frames /usr/local/lib/python3.6/dist-packages/tflearn/variables.py in () 5 import tflearn 6 ----> 7 from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope 8 from tensorflow.python.framework import ops 9 from tensorflow.python.ops import variable_scope ModuleNotFoundError: No module named 'tensorflow.contrib'"

I believe this is because tflearn won't work with tensorflow 2.0. (a possible explanation here: https://github.com/tensorflow/tensorflow/issues/30794) This is certainly because you wrote your notebook before tensorflow 2.0 was available.

I am not using the Docker image you provided, and I know that would solve the problem! However, do you intend to correct this kind of issue / maintain the examples in the future?

Thank you, Bogdan

rickiepark commented 4 years ago

Hi Bogdan,

You're right. tflearn is deprecated. But you can use oxflower17.npz file that I made in TF 1.x :)

!wget https://bit.ly/36QytdH -O oxflower17.npz
import numpy as np

data = np.load('oxflower17.npz')
X = data['X']
Y = data['Y']

Please refer to https://github.com/rickiepark/dl-illustrated/blob/master/notebooks/10-2.alexnet_in_keras.ipynb

Cheers, Haesun

exAbstracto commented 4 years ago

Hi Haesun,

Problem solved, thank you! :)

Bogdan

jonkrohn commented 4 years ago

Amazing, Haesun (@rickiepark)! Thank you for the "hot fix", which I may take advantage of for the second edition of Deep Learning Illustrated when I release that a few years from now!

And delighted to hear that you're enjoying the book, Bogdan (@exAbstracto)!

In future, Bogdan, you may find my Deep Learning with TensorFlow, Keras, and PyTorch repo helpful, as it features code notebooks that are extremely similar to those that I use in Deep Learning Illustrated but updated library versions, including TensorFlow 2 (Dockerfile here).