建议在python3下运行
需要另外安装的第三方库主要有:theano keras gym matplotlib
可以参考以下代码进行安装
pip3 install theano keras gym matplotlib
- 需将环境文件ChannelEnv.pv放到gym的安装目录下。如
/usr/local/lib/python3.6/site-packages/gym/envs/classic_control/
- 打开1中目录中的
__init__.py
文件,加入语句:from gym.envs.classic_control.ChannelEnv import ChannelEnv
- 进入gym安装目录的
gym/gym/envs/
打开__init__.py
,添加代码:
register( id='Channel-v0',
entry_point='gym.envs.classic_control:ChannelEnv',
max_episode_steps=200, reward_threshold=100.0, )
使用python3运行channel1.py
see Conda documentation#Installation and choose anaconda3
- Create a conda environment with python 3.6:
conda create --name gymtestbed python=3.6
- Switch to created environment:
source <anaconda path>/bin/activate gymtestbed
. For example,source ~anaconda3/bin/activate gymtestbed
. see also Conda documentation#Managing Environments
- See Conda documentation#Managing packages to install
theano
,keras
andmatplotlib
- Install
gym
using:
git clone https://github.com/openai/gym.git
cd gym
pip install -e '.[classic_control]'
see also the github page of gym.
- Open
<where you clone the gym respo>gym/gym/envs/__init__.py
, add:
register( id='Channel-v0',
entry_point='gym.envs.classic_control:ChannelEnv',
max_episode_steps=200, reward_threshold=100.0, )
- Open
<where you clone the gym respo>/gym/gym/envs/classic_control/__init__.py
and add:from gym.envs.classic_control.ChannelEnv import ChannelEnv
- Use
git clone
to clone this respo. cd channel_dqn
and openrun.sh
and change the line 3 and 4 of code.
#!/bin/bash
# Update the environment, then run the agent
cp ChannelEnv.py <where you clone the gym respo>/gym/gym/envs/classic_control/ChannelEnv.py
cp channelConfig.py <where you clone the gym respo>/gym/gym/envs/classic_control/channelConfig.py
python ./channel1.py
- Use
chmod +x ./run.sh
to give execute permission. - Run the program.
./run.sh
The run.sh
file will copy the ChannelEnv.py
into the gym and execute program channel1.py