Work around TF Agents issue: env.step(1) => env.step(np.array(1))
parent
f225f59780
commit
8ebdcffc6b
|
@ -1860,13 +1860,20 @@
|
||||||
"env.reset()"
|
"env.reset()"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"**Warning**: since TF Agents 0.4.0, there seems to be an issue with passing an integer to the `env.step()` method (it raises an `AttributeError`). You need to wrap it in a NumPy array, as done below. Please see [TF Agents Issue #520](https://github.com/tensorflow/agents/issues/520) for more details."
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 82,
|
"execution_count": 82,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"env.step(1) # Fire"
|
"env.step(np.array(1)) # Fire"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2074,9 +2081,9 @@
|
||||||
"source": [
|
"source": [
|
||||||
"env.seed(42)\n",
|
"env.seed(42)\n",
|
||||||
"env.reset()\n",
|
"env.reset()\n",
|
||||||
"time_step = env.step(1) # FIRE\n",
|
"time_step = env.step(np.array(1)) # FIRE\n",
|
||||||
"for _ in range(4):\n",
|
"for _ in range(4):\n",
|
||||||
" time_step = env.step(3) # LEFT"
|
" time_step = env.step(np.array(3)) # LEFT"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2215,7 +2222,7 @@
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"source": [
|
"source": [
|
||||||
"Create the replay buffer:"
|
"Create the replay buffer (this may use a lot of RAM, so please reduce the buffer size if you get an out-of-memory error):"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -2521,7 +2528,7 @@
|
||||||
" lives = tf_env.pyenv.envs[0].ale.lives()\n",
|
" lives = tf_env.pyenv.envs[0].ale.lives()\n",
|
||||||
" if prev_lives != lives:\n",
|
" if prev_lives != lives:\n",
|
||||||
" tf_env.reset()\n",
|
" tf_env.reset()\n",
|
||||||
" tf_env.pyenv.envs[0].step(1)\n",
|
" tf_env.pyenv.envs[0].step(np.array(1))\n",
|
||||||
" prev_lives = lives\n",
|
" prev_lives = lives\n",
|
||||||
"\n",
|
"\n",
|
||||||
"watch_driver = DynamicStepDriver(\n",
|
"watch_driver = DynamicStepDriver(\n",
|
||||||
|
@ -2790,7 +2797,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.7.6"
|
"version": "3.7.8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
Loading…
Reference in New Issue