'Setting up keras-rl2 on my M1 Macbook Pro

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?



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kaleba KB Keitshokile