Setting up keras-rl2 on my M1 Macbook Pro - python

I am working on a project on Reinforcement Learning - and completely new at this. I installed keras-rl as
pip install keras-rl, however it caused an error as many has mentioned:
TypeError: Keras symbolic inputs/outputs do not implement `__len__`. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.
And the solution for this is to used keras-rl2. Howver I cannot install keras-rl2 on my Mac M1 as the output is following:
ERROR: Cannot install keras-rl2==1.0.0, keras-rl2==1.0.1, keras-rl2==1.0.2, keras-rl2==1.0.3, keras-rl2==1.0.4 and keras-rl2==1.0.5 because these package versions have conflicting dependencies.
When I tried a specific version, i.e
pip install keras-rl2==1.0.5, the output is:
ERROR: Could not find a version that satisfies the requirement tensorflow (from keras-rl2) (from versions: none)
ERROR: No matching distribution found for tensorflow
I have tensorflow 2.6.0 installed by Apple Developer guide. Any idea how I can install keras-rl2?

1. To install Tensorflow on M1 Macs
https://developer.apple.com/metal/tensorflow-plugin/
2. To Install Keras-rl2
Open a terminal window and run these commands from:
https://github.com/keras-rl/keras-rl (last line changed)
git clone https://github.com/wau/keras-rl2.git
cd keras-rl
python3 setup.py install
The setup.py script will still tell you that it can't find a TensorFlow version but you will still be able to import it using:
import rl

Related

Error while installing TF Object Detection API

I am trying to install Tensorflow Object Detection API, following those instructions. Everything goes well till the moment I have to run python -m pip install within the models/research directory. It starts collecting and installing the various packages, but when it reaches the installation of tf-models-official, it produces the following error :
ERROR: Cannot install object-detection because these package versions have conflicting dependencies.
The conflict is caused by:
tf-models-official 2.7.0 depends on tensorflow-addons
tf-models-official 2.6.1 depends on tensorflow-addons
tf-models-official 2.6.0 depends on tensorflow-addons
tf-models-official 2.5.1 depends on tensorflow-addons
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
I did up a bit of digging online, but didn't manage to find anything in the Github repo of tensorflow or other websites. I am using Tensorflow 2.7.0 and Python 3.9.2, on a Linux 64-bit OS. I also tried with Python 3.7.12 but the same error persisted, while manual installation of tensorflow-addons using pip install indicates that no matching distribution was found.
python-3.10.2-amd64: error
python-3.9.10-amd64: ok
python-3.9.2-amd64: ok
python-3.8.10-amd64: ok
python -m pip install --use-feature=2020-resolver tensorflow
'--use-feature=2020-resolver' could be a good solution.
Did you use "tensorflow==2.5.0"?
Don't use specific version like "==2.5.0".
UPDATE
See https://pypi.org/project/tensorflow/#history
tensorflow 2.8.0 (Feb 3, 2022)
I installed tf 2.7.0 and then when I tried to install object detection, tf was reinstalled into tf 2.8.0. So I thought it is weird but I didn't know that tf 2.8.0 doesn't exist yet when you tried to install object detection.
If you try again, tf will be reinstalled automatically into 2.8.0.

Python package (tensorflow) displays mismatching versions between pip list and .__version__ output

I suddenly encounter this situation today, all below output is under the same environment.
pip show tensorflow, the output gives:
Name: tensorflow
Version: 1.14.0rc1
But, if I enter python
python
>>> import tensorflow as tf
>>> print(tf.__version__) . It gives:
'1.13.1'
I am sure I am using the same python under the environment I need with pure terminal or in IDE. This is weird, cuz I used to not having this issue. I just installed few other packages these two days, but I believe they have nothing to do with tensorflow. And you can also verify this through pip show tensorflow or pip list output to see the version is 1.14.0rc1. So why when I actually use python, the tensorflow is not loaded properly?
Solved it by the following:
(under the same environment)
pip uninstall tensorflow (in order to reinstall tensorflow the right version)
pip install tensorflow==1.14.0rc1
Note during installing, there is a piece of info from the terminal:
Installing collected packages: tensorflow
Attempting uninstall: tensorflow
Found existing installation: tensorflow 1.13.1
Uninstalling tensorflow-1.13.1:
Successfully uninstalled tensorflow-1.13.1
So it seems like the tensorflow 1.13.1 has been accidentally installed previously, and whenever in a python program import tensorflow, during searching stage, it hits the tensorflow==1.13.1 before finding the 1.14.0rc1 version. Altho pip list only displays tensorflow==1.14.0rc1 but not tensorflow==1.13.1 might also be due to its internal search or duplicated package resolve mechanism.

Is there any other way to install Tensorflow on python 3.9.1?

When I try to install tensorflow on python 3.9, I get following error:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
I know that Tensorflow is supported only up to Python 3.8. Is there any other way to install tensorflow in python 3.9.1 without installing an older version of python?
It is not possible now. This problem is an active trend in this Tensorflow GitHub issue.
There are some issues with the dependencies for the underlying C++ code. So they expect to have it available for the v2.5. However, it will start as a nightly build, so if you are planning to develop some production-ready application, I recommend you download a lower Python version to avoid waiting for a long time
until they release a stable build.

Tensorflow issues when downloading and importing

I'm trying to use tensorflow more accurately keras but it used tensorflow backend. I have had to convert my python to 3.6.2 in order to download tensorflow and even though it installs when I go to import it doesnt work saying :
ModuleNotFoundError: No module named 'tensorflow'
So i have tried installing Anaconda and performing this input:
conda create -n tensorflow_cpu pip python=3.6 #also tried with just tensorflow
activate tensorflow_cpu
pip install --ignore-installed --upgrade tensorflow
Then I get this error:
ERROR: Could not find a version that satisfies the requirement tensorflow_cpu (from versions: none)
ERROR: No matching distribution found for tensorflow_cpu
So now I am completely stuck. Why is it so hard to just import a module. Why hasn't tensorflow made the effort to make it work with newer versions of python. I am trying to perform machine learning projects but this issue is demotivating me massively and is turning me away from it all together.
If anyone has a solution or reason could you please let me know it simple matters so i can follow thoroughly. Thanks for your time.
If you are on Windows install Python 3.6.x and then Tensorflow as of 8-13-2018 and if you are on Linux just follow this link's instruction https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html .

How to install keras on Win10?

I know there are a lot of tutorials of installing keras on win. But I am faced with a weird problem and I cannot find a solution on Google.
The version of python I used is 2.7(anaconda 64bit).
When I typed 'pip install keras' in cmd, an error occurred.
It is said that no matching distribution found for tensorflow(from keras).
I googled it and one saying goes that this problem occurred when python is 32bit on windows. However, my python is 64-bit, so this saying does not hold.
I want to know how to handle this, given that I want to use theano as keras backend instead of tensorflow.
I think the problem is that TensorFlow on Windows only support Python 3.5.X.
You should try installing anaconda3.
Source: https://www.tensorflow.org/install/install_windows
using commad pip install -v -v -v keras may offer you more information about this
and I find this commad may download Keras tar file in site https://pypi.python.org/simple/keras/
and after download file, it will check the requires.txt in Keras.egg-info
then i find in Keras 2.0.0 it require tensorflow instead of theano in this version, otherwise you may fail to install
so the solution is, download the other keras in site which requires theano not tensorflow, and unpack it, then cd its directory, and use python setup.py install to install this version of keras

Categories