Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import the Tensorflow libraries in python?

A very basic question.

I am trying to install tensorflow library in Anaconda python(spyder).

import tf.contrib.keras.preprocessing

Its is giving me error as "No module found". I also tried import tensorflow.contrib.keras.preprocessing

I also tried from tf.contrib.keras.preprocessing.text import Tokenizer.

This also doesnt work

However I verified this in the tensorflow website, and it is present. The link to the library is https://www.tensorflow.org/api_docs/python/tf/contrib/keras/preprocessing.

I tried to pip and conda install. But that also throwing out error.

From anaconda prompt i typed this:

activate tensorflow 
pip install tf.contrib.keras.preprocessing
conda install tf.contrib.keras.preprocessing

Is there anything i miss out, Please correct me.

like image 949
Doubt Dhanabalu Avatar asked Jan 30 '23 19:01

Doubt Dhanabalu


1 Answers

You are doing it wrong as tf is not the name of the tensorflow module but an alias in the tutorials.

import tensorflow as tf

Thus try this:

from tensorflow.contrib.keras.preprocessing.text import Tokenizer

From your comments it seems that the module might not be installed so you can check in the list of installed packages:

conda list

If not present, install it with pip. Follow the doc.

like image 86
tupui Avatar answered Feb 02 '23 08:02

tupui