Search code examples
pythontensorflowdeep-learning

Tensorflow TFLearn working example with TFLearn


I'm approaching to the world of deep learning, and the framework that I'm using is Tensorflow. In order to start quickly, I've seen that there are high level API called TFLearn, which makes the creation of a network a lot easier. Unfortunately, there are no working examples. In particular, I'm trying this example:

Example

but it can't find the layers. I've tried to import tflearn in this way:

import tensorflow.contrib.learn as tflearn

and the dataset in this way

import tensorflow.contrib.learn.python.learn.datasets.mnist as mnist

and they works, but I'm still not able to use the layers.

EDIT

I also tried to import in this way (as reported on tflearn github page):

import tensorflow.contrib.learn.python.learn as tflearn

and I get this error:

AttributeError: module 'tensorflow.contrib.learn.python.learn' has no attribute 'conv_2d'

What can I do?


Solution

  • Don't use

    import tensorflow.contrib.learn as tflearn
    

    Instead install tflearn in your terminal, using installation guide http://tflearn.org/installation/

    Then, import like:

    import tflearn
    from tflearn.layers.core import input_data, dropout, fully_connected
    from tflearn.layers.conv import conv_2d, max_pool_2d
    from tflearn.layers.estimator import regression
    

    This way you can use the layers.