I am reading "Hands-On Machine Learning with Scikit-Learn, Keras and Tensorflow" and installed Tensorflow 2 as follows:
$ python3 -m pip install --upgrade tensorflow
In the jupyter notebook I tried to import Tensorflow as follows:
import tensorflow as tf
But then I get the following error message:
The kernel appears to have died. It will restart automatically
I know there is a bunch of StackOverflow threads about this topic. I have read them all. Some of them are old, some are new. Most of them suggest to downgrade the Tensorflow version to 1.5. But when I do that I can not use some of the methods of the Keras API (e.g. load_data() could not be found).
Is there anyone who have found a solution for that?
The second version of the textbook is all about TensorFlow version 2 so you have to use TensorFlow version 2 to use code. if there is a problem get the first version of the textbook which uses TensorFlow 1.
But I suggest learning TensorFlow 2 as it is the latest version.
if you are using anaconda Try installing TensorFlow 2 in a new environment.
To create a new environment open anaconda prompt.
conda create -n envname python=3.6
and then activate the environment
activate envname
Now try installing TensorFlow 2 and other necessary modules
and check.
If it does not work the best solution is to use google colab(colab.research.google.com/).where you can do everything online, you can even have free GPU.
Related
Please guide me the steps and source to install Tensorflow and keras on Windows 10 home edition using python (pip)?
Try the following at command prompt:
pip install --upgrade tensorflow
pip install --upgrade keras
Also, refer the following link for more detail:
https://www.tensorflow.org/install/pip
I had many issues installing tensorflow and keras by using: pip install...
I would suggest to you Anaconda.navigator. Although It is slower than Anaconda prompt, it helped me to understand the installation process. It worked for me.
First, I uninstalled old versions of Python and Anaconda and Installed Anaconda for Python 3.7 from here (Anaconda3-2019.10-Windows-x86_64.exe) (At this time Tensorflow and keras do not support Python 3.8).
In the Anaconda.Navigator I went to "environments" select "create" (create new environment) and name it. Then, on your new environment select what ever you want to install (tensorflow, tensorflow-gpu, keras, keras-gpu). Make sure that Python lower than 3.8 is on your new environment. This video1 and video2 may help you.
I hope you solve your problem.
I'm quite new to Keras and Tensorflow, and I'd like to export my model to Javascript to be able to run it in a web browser. This worked great with WebDNN a year ago.
Today I updated my Tensorflow installation and ran the whole model again. Unfortunately, I'm now getting the error
NotImplementedError: WebDNN supports TensorFlow >=v1.2.0,<=v1.4.0 Currently, TensorFlow 1.13.1 is installed.
How can I "downgrade" my model data to the Tensorflow 1.4.0 format so that it runs with WebDNN?
Should I create a new Anaconda environment, install Tensorflow 1.4.0 there, and move the model weights to that environment? Or should I try to adapt the code of WebDNN so that it works with TensorFlow 1.13?
You can try pip uninstall tensorflow and then pip install tensorflow-gpu==1.4.0.
It is good practice to install your dependencies in separate environments, to avoid global pollution.
I have an issue using keras backend. I set up tensorflow as the backend. I check the ./keras/keras.json, the activate.d and activate.sh to have tensorflow as backend. I also tried to force the envs variable to tensorflow.
The first time a run keras on the jupyter, it works fine. I can also import tensorflow without any bugs.
However when I use jupyter notebook now, the backend is theano.
I try to import keras on ipython and the backend is tensorflow.
I install keras, tensorflow and theano with conda.
python version : 3.6
keras : 2.0.6
tensorflow : 1.3.0
theano : 0.9
OS : win10
I try different ways to change the backend to tensorflow for jupyter notebook but it does not seem to work.
Usually, with conda, we create specific environments that are (theoretically) independent from the others.
I suggest you create a tensorflow environment using conda. Using the command prompt:
conda create -n myTensorflowEnv python=3.5
And then you activate this environment:
activate myTensorflowEnv
The name of your environment should then appear in between parentheses at the beginning of the command prompt. (In case this doesn't work, you may need to setup some vars: How to activate an Anaconda environment)
Inside this environment, you install everything you need: Tensorflow, keras and other dependencies. This process will depend on what you want, though, cpu, gpu, compilations, etc.
You should probably install jupyter in this environment as well. (And perhaps -- only if you have the terrible bug I mentioned in my comment -- uninstall the other jupyters first).
If everything goes well, you will be able to use tensorflow in this environment if you run jupyter from this environment.
I am trying to install Tensorflow on a Windows 7 laptop in order to use jupyter notebook to play around with the object detection notebook in Github. I am facing this error:
ImportError Traceback (most recent call
last) in ()
4 import sys
5 import tarfile
----> 6 import tensorflow as tf
7 import zipfile
8
ImportError: No module named tensorflow
I am getting the above error when I start the Jupyter Notebook from inside the Conda environment in Windows 7. I have installed Python 3.5.4 & within conda environment, tensorflow as well.
I am also getting ... not recognized as an internal/external... for $ command while giving $ python and sometimes also for pip3 I have included several file paths in Environment Variables. Can you please suggest me what to do. I am using the Conda env as I feel I have a problem in having Windows Service Pack 1.
Make sure your Tensorflow folder is somewhere that the environment will look, such as [Python install directory]/Lib/Site-packages
If you are using Anaconda to manage your installation, be aware that it is community supported and not officially supported by Google. Google has a detailed guide on how to install Tensorflow on Windows as well as how to validate the installation. Follow their steps carefully and be aware you may need to start the process over if you miss a step.
1) Make sure you start with a clean Conda Environment for Tensorflow. You will need to specifiy Python version 3.5. You can do this by running the command,
C:> conda create -n tensorflow python=3.5
2) Once the new Conda environmnet is created, activate it. This step is commonly overlooked.
C:> activate tensorflow
(tensorflow)C:> # The Conda environment may appear before the drive letter
3) With the Tensorflow environment active, issue the pip command to install the appropriate Tensorflow version. To keep things simple, I assume you will be installing the CPU version. If you need the GPU version, refer to the Google guide since there are other things you will need to do in order to set up the NVIDIA drivers.
(tensorflow)C:> pip install --ignore-installed --upgrade tensorflow
Note the flags included on the pip install command.
To make sure that Tensorflow is installed properly, validate the installation. Do this by double checking that the Tensorflow Conda environment is active and starting a python console. Once the console is running type the following sample program, suggested by Google's guide.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
If you are new to Tensorflow, this code may not make sense. What it does is import the Tensorflow library, assign a variable called "hello" to a Tensorflow constant tensor. Tensorflow is a library designed to operate on Tensor data objects. The next line initiates a Tensorflow session which loads all the data objects. The final line prints the output of Session.run() on the hello constant object. If everything is set up correctly you should see
Hello, TensorFlow!
output on the console. If you don't, check to common installation issues included in Google's Tensorflow install guide.
This is my first question on stackoverflow, please bear with me as I will do my best to provide as much info as possible.
I have a windows 10, 6-bit processor. My end goal is to use keras within spyder. The first thing I did was update python to 3.6 and install tensorflow, which seemed to work. When I attempted to get keras, however, it wasn't working, and I read that keras worked on python 3.5. I successfully installed keras on python 3.5, which automatically installed theano as the backend.
But now I have two spyder environments, one running off of python 3.5, one off of 3.6. The 3.5 reads keras but doesn't go through with any modules because it cannot find tensorflow. The 3.6 can read tensorflow, but cannot find keras.
Please let me know what you would recommend. Thank you!
Create a virtualenv with python 3.5 installed.
I dealt with this same issue, using Jupyter Notebook. Didn't understand why you would even need a virtualenv until I learned from this roadblock.
Full details on installing and setting up a virtualenv can be found here:
http://pymote.readthedocs.io/en/latest/install/windows_virtualenv.html
Odd, the installation instructions say that TF only supports Python 3.5 on Windows. I would uninstall TF with pip uninstall tensorflow (if you installed it with pip to begin with) using pip from your Python 3.6 path, then re-install (pip install --upgrade tensorflow) making sure that you are running pip from your Python 3.5 path.
I had some issues with my tensorflow's installation too.
I personnaly used anaconda to solve the problem.
After installing anaconda (Maybe uninstall the old one if you already have one), launch an anaconda prompt and input conda create -n tensorflow python=3.5, afther that, you must activate it with activate tensorflow.
Once it's done, you have to install tensorflow on your python 3.5.
For that, use:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.0rc1-cp35-cp35m-win_amd64.whl
for cpu version
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.2.0rc1-cp35-cp35m-win_amd64.whl for gpu version
You now have the r1.2 version of tensorflow.
Then, just use pip install keras and keras will be installed.
Now, all you have to do is launch anaconda navigator, select tensorflow on the scrolling menu and launch spyder/jupyter.
You can now use Keras with a tensorflow backend in Python 3.5
Hope it helped someone ! (It take me so much time to find it by myself)