Massyanya
Massyanya

Reputation: 2934

Importing keras-rl package into conda environment

I've installed keras-rl package on my computer, using their instructions:

git clone https://github.com/matthiasplappert/keras-rl.git
cd keras-rl
python setup.py install

So my conda environment sees this package, however when I am trying to import it in Spyder as a part of my code, i.e. import keras-rl, I get the following error:

SyntaxError: invalid syntax

with a pointer to the dash of keras-rl.

Question: How could I import the keras-rl (or any other package with the dash in the name) in Spyder?

Upvotes: 2

Views: 4826

Answers (3)

Erfan Memarian
Erfan Memarian

Reputation: 1

I had the same problem. After lots of examination I found the correct way. You can import RL by writing this:

"import rl"

and then write your code like:

rl.core.Agent()

Upvotes: 0

Ratheesh A - Intel
Ratheesh A - Intel

Reputation: 196

We can install keras-rl by simply executing

         pip install keras-rl

There are various functionalities from keras-rl that we can make use for running RL based algorithms in a specified environment

few examples below

from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory

This is how we can use the package.

Upvotes: 1

Nehal J Wani
Nehal J Wani

Reputation: 16639

If you look at the examples present in the github repository, you will see that the various functionalities are imported from rl. Like this:

(root) ~/condaexpts/keras-rl/examples $ grep -h import * | grep rl
from rl.agents import ContinuousDQNAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.core import Processor
from rl.agents.cem import CEMAgent
from rl.memory import EpisodeParameterMemory
from rl.agents import DDPGAgent
from rl.memory import SequentialMemory
from rl.random import OrnsteinUhlenbeckProcess
from rl.agents.dqn import DQNAgent
from rl.policy import LinearAnnealedPolicy, BoltzmannQPolicy, EpsGreedyQPolicy
from rl.memory import SequentialMemory
from rl.core import Processor
from rl.callbacks import FileLogger, ModelIntervalCheckpoint
from rl.agents.dqn import DQNAgent
from rl.policy import BoltzmannQPolicy
from rl.memory import SequentialMemory

Upvotes: 0

Related Questions