Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow examples all fail due to AttributeError: 'module' object has no attribute 'datasets'

I have built v0.8.0 of tensorflow using pip install, but when I try any of the skflow examples, they all fail due to

AttributeError: 'module' object has no attribute 'datasets'

Which is as a result of this

from tensorflow.contrib import learn

### Training data

# Downloads, unpacks and reads DBpedia dataset.
dbpedia = learn.datasets.load_dataset('dbpedia')
like image 390
robsalzwedel Avatar asked May 13 '16 09:05

robsalzwedel


2 Answers

Several people have encountered this. Please install latest version, .e.g. one of the recent nightly builds.

run this from the command line

pip3 install --upgrade http://ci.tensorflow.org/view/Nightly/job/nightly-matrix-cpu/TF_BUILD_CONTAINER_TYPE=CPU,TF_BUILD_IS_OPT=OPT,TF_BUILD_IS_PIP=PIP,TF_BUILD_PYTHON_VERSION=PYTHON3,label=cpu-slave/lastSuccessfulBuild/artifact/pip_test/whl/tensorflow-0.8.0-cp34-cp34m-linux_x86_64.whl
like image 195
Yuan Tang Avatar answered Nov 01 '22 20:11

Yuan Tang


I've found a less annoying way around this problem is to just download and load the data manually. It's quite easy, here is how I did it.

from tensorflow.contrib import learn

# Downloads, unpacks and reads DBpedia dataset.
## dbpedia = learn.datasets.load_dataset('dbpedia')
## BUT THAT ABOVE FUNCTION DOESN'T WORK SO....

## MANUALLY DOWNLOAD THE DATA FROM THIS LINK:  
##     https://googledrive.com/host/0Bz8a_Dbh9Qhbfll6bVpmNUtUcFdjYmF2SEpmZUZUcVNiMUw1TWN6RDV3a0JHT3kxLVhVR2M/dbpedia_csv.tar.gz


## MANUALLY UNPACK THE DATA BY DOUBLE CLICKING IT
##     make sure the paths are correct


## LOAD IT LIKE YOU WOULD A REGULAR CSV FILE.
train = pandas.read_csv('dbpedia_csv/train.csv', header=None)
X_train, y_train = train[2], train[0]
test = pandas.read_csv('dbpedia_csv/test.csv', header=None)
X_test, y_test = test[2], test[0]
like image 3
Weezy.F Avatar answered Nov 01 '22 18:11

Weezy.F