Final commit for assignment 05
This commit is contained in:
@ -2,19 +2,19 @@
|
|||||||
"cells": [
|
"cells": [
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 1,
|
"execution_count": 28,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"import tensorflow as tf\n",
|
"import tensorflow as tf\n",
|
||||||
"from tensorflow import keras\n",
|
"from tensorflow import keras\n",
|
||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import gym"
|
"import gym # == 0.26.2"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 2,
|
"execution_count": 33,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@ -58,7 +58,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 3,
|
"execution_count": 30,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
@ -75,12 +75,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 4,
|
"execution_count": 31,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"class Agent(object):\n",
|
"class Agent(object):\n",
|
||||||
" def __init__(self, alpha, gamma, n_actions, epsilon, batch_size, input_dims, epsilon_dec=0.996, epsilon_end=0.01, mem_size=1000000, fname=\"dqn_model.keras\"):\n",
|
" def __init__(self, alpha, gamma, n_actions, epsilon, batch_size, input_dims, epsilon_dec=0.98, epsilon_end=0.01, mem_size=1000000, fname=\"dqn_model.keras\"):\n",
|
||||||
" self.action_space = [i for i in range(n_actions)]\n",
|
" self.action_space = [i for i in range(n_actions)]\n",
|
||||||
" self.n_actions = n_actions\n",
|
" self.n_actions = n_actions\n",
|
||||||
" self.gamma = gamma\n",
|
" self.gamma = gamma\n",
|
||||||
@ -102,7 +102,7 @@
|
|||||||
" if rand < self.epsilon:\n",
|
" if rand < self.epsilon:\n",
|
||||||
" action = np.random.choice(self.action_space)\n",
|
" action = np.random.choice(self.action_space)\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" actions = self.q_eval.predict(state)\n",
|
" actions = self.q_eval.predict(state, verbose=0)\n",
|
||||||
" action = np.argmax(actions)\n",
|
" action = np.argmax(actions)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" return action\n",
|
" return action\n",
|
||||||
@ -115,8 +115,9 @@
|
|||||||
" action_values = np.array(self.action_space, dtype=np.int8)\n",
|
" action_values = np.array(self.action_space, dtype=np.int8)\n",
|
||||||
" action_indices = np.dot(action, action_values)\n",
|
" action_indices = np.dot(action, action_values)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" q_eval = self.q_eval.predict(state)\n",
|
"\n",
|
||||||
" q_next = self.q_eval.predict(new_state)\n",
|
" q_eval = self.q_eval.predict(state, verbose=0)\n",
|
||||||
|
" q_next = self.q_eval.predict(new_state, verbose=0)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" q_target = q_eval.copy()\n",
|
" q_target = q_eval.copy()\n",
|
||||||
"\n",
|
"\n",
|
||||||
@ -137,408 +138,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"episode 0 score 16.00 average score 16.00\n",
|
|
||||||
"episode 1 score 20.00 average score 18.00\n",
|
|
||||||
"episode 2 score 20.00 average score 18.67\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 40ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 3 score 21.00 average score 19.25\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 3ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 4ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 3ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 17ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 16ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 4 score 58.00 average score 27.00\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 6ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 5 score 13.00 average score 24.67\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 6 score 14.00 average score 23.14\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 20ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 7 score 14.00 average score 22.00\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"episode 8 score 11.00 average score 20.78\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 17ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 4ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 16ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 14ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"1/1 [==============================] - 0s 15ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 2ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n",
|
|
||||||
"2/2 [==============================] - 0s 1ms/step\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"ename": "KeyboardInterrupt",
|
|
||||||
"evalue": "",
|
|
||||||
"output_type": "error",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
|
||||||
"Cell \u001b[0;32mIn[9], line 13\u001b[0m\n\u001b[1;32m 11\u001b[0m observation, info \u001b[39m=\u001b[39m env\u001b[39m.\u001b[39mreset()\n\u001b[1;32m 12\u001b[0m \u001b[39mwhile\u001b[39;00m \u001b[39mnot\u001b[39;00m done:\n\u001b[0;32m---> 13\u001b[0m action \u001b[39m=\u001b[39m agent\u001b[39m.\u001b[39;49mchoose_action(observation)\n\u001b[1;32m 14\u001b[0m observation_, reward, done, _, info \u001b[39m=\u001b[39m env\u001b[39m.\u001b[39mstep(action)\n\u001b[1;32m 15\u001b[0m score \u001b[39m+\u001b[39m\u001b[39m=\u001b[39m reward\n",
|
|
||||||
"Cell \u001b[0;32mIn[4], line 24\u001b[0m, in \u001b[0;36mAgent.choose_action\u001b[0;34m(self, state)\u001b[0m\n\u001b[1;32m 22\u001b[0m action \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39mrandom\u001b[39m.\u001b[39mchoice(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39maction_space)\n\u001b[1;32m 23\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 24\u001b[0m actions \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mq_eval\u001b[39m.\u001b[39;49mpredict(state)\n\u001b[1;32m 25\u001b[0m action \u001b[39m=\u001b[39m np\u001b[39m.\u001b[39margmax(actions)\n\u001b[1;32m 27\u001b[0m \u001b[39mreturn\u001b[39;00m action\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/utils/traceback_utils.py:65\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 63\u001b[0m filtered_tb \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 64\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m---> 65\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 66\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 67\u001b[0m filtered_tb \u001b[39m=\u001b[39m _process_traceback_frames(e\u001b[39m.\u001b[39m__traceback__)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/training.py:2521\u001b[0m, in \u001b[0;36mModel.predict\u001b[0;34m(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[1;32m 2512\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mValueError\u001b[39;00m:\n\u001b[1;32m 2513\u001b[0m warnings\u001b[39m.\u001b[39mwarn(\n\u001b[1;32m 2514\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mUsing Model.predict with MultiWorkerMirroredStrategy \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 2515\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mor TPUStrategy and AutoShardPolicy.FILE might lead to \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 2518\u001b[0m stacklevel\u001b[39m=\u001b[39m\u001b[39m2\u001b[39m,\n\u001b[1;32m 2519\u001b[0m )\n\u001b[0;32m-> 2521\u001b[0m data_handler \u001b[39m=\u001b[39m data_adapter\u001b[39m.\u001b[39;49mget_data_handler(\n\u001b[1;32m 2522\u001b[0m x\u001b[39m=\u001b[39;49mx,\n\u001b[1;32m 2523\u001b[0m batch_size\u001b[39m=\u001b[39;49mbatch_size,\n\u001b[1;32m 2524\u001b[0m steps_per_epoch\u001b[39m=\u001b[39;49msteps,\n\u001b[1;32m 2525\u001b[0m initial_epoch\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m,\n\u001b[1;32m 2526\u001b[0m epochs\u001b[39m=\u001b[39;49m\u001b[39m1\u001b[39;49m,\n\u001b[1;32m 2527\u001b[0m max_queue_size\u001b[39m=\u001b[39;49mmax_queue_size,\n\u001b[1;32m 2528\u001b[0m workers\u001b[39m=\u001b[39;49mworkers,\n\u001b[1;32m 2529\u001b[0m use_multiprocessing\u001b[39m=\u001b[39;49muse_multiprocessing,\n\u001b[1;32m 2530\u001b[0m model\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m,\n\u001b[1;32m 2531\u001b[0m steps_per_execution\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_steps_per_execution,\n\u001b[1;32m 2532\u001b[0m )\n\u001b[1;32m 2534\u001b[0m \u001b[39m# Container that configures and calls `tf.keras.Callback`s.\u001b[39;00m\n\u001b[1;32m 2535\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39misinstance\u001b[39m(callbacks, callbacks_module\u001b[39m.\u001b[39mCallbackList):\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:1678\u001b[0m, in \u001b[0;36mget_data_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 1676\u001b[0m \u001b[39mreturn\u001b[39;00m _ClusterCoordinatorExactEvalDataHandler(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[1;32m 1677\u001b[0m \u001b[39mreturn\u001b[39;00m _ClusterCoordinatorDataHandler(\u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n\u001b[0;32m-> 1678\u001b[0m \u001b[39mreturn\u001b[39;00m DataHandler(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:1285\u001b[0m, in \u001b[0;36mDataHandler.__init__\u001b[0;34m(self, x, y, sample_weight, batch_size, steps_per_epoch, initial_epoch, epochs, shuffle, class_weight, max_queue_size, workers, use_multiprocessing, model, steps_per_execution, distribute, pss_evaluation_shards)\u001b[0m\n\u001b[1;32m 1282\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_steps_per_execution \u001b[39m=\u001b[39m steps_per_execution\n\u001b[1;32m 1284\u001b[0m adapter_cls \u001b[39m=\u001b[39m select_data_adapter(x, y)\n\u001b[0;32m-> 1285\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_adapter \u001b[39m=\u001b[39m adapter_cls(\n\u001b[1;32m 1286\u001b[0m x,\n\u001b[1;32m 1287\u001b[0m y,\n\u001b[1;32m 1288\u001b[0m batch_size\u001b[39m=\u001b[39;49mbatch_size,\n\u001b[1;32m 1289\u001b[0m steps\u001b[39m=\u001b[39;49msteps_per_epoch,\n\u001b[1;32m 1290\u001b[0m epochs\u001b[39m=\u001b[39;49mepochs \u001b[39m-\u001b[39;49m initial_epoch,\n\u001b[1;32m 1291\u001b[0m sample_weights\u001b[39m=\u001b[39;49msample_weight,\n\u001b[1;32m 1292\u001b[0m shuffle\u001b[39m=\u001b[39;49mshuffle,\n\u001b[1;32m 1293\u001b[0m max_queue_size\u001b[39m=\u001b[39;49mmax_queue_size,\n\u001b[1;32m 1294\u001b[0m workers\u001b[39m=\u001b[39;49mworkers,\n\u001b[1;32m 1295\u001b[0m use_multiprocessing\u001b[39m=\u001b[39;49muse_multiprocessing,\n\u001b[1;32m 1296\u001b[0m distribution_strategy\u001b[39m=\u001b[39;49mtf\u001b[39m.\u001b[39;49mdistribute\u001b[39m.\u001b[39;49mget_strategy(),\n\u001b[1;32m 1297\u001b[0m model\u001b[39m=\u001b[39;49mmodel,\n\u001b[1;32m 1298\u001b[0m pss_evaluation_shards\u001b[39m=\u001b[39;49mpss_evaluation_shards,\n\u001b[1;32m 1299\u001b[0m )\n\u001b[1;32m 1301\u001b[0m strategy \u001b[39m=\u001b[39m tf\u001b[39m.\u001b[39mdistribute\u001b[39m.\u001b[39mget_strategy()\n\u001b[1;32m 1303\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_current_step \u001b[39m=\u001b[39m \u001b[39m0\u001b[39m\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:355\u001b[0m, in \u001b[0;36mTensorLikeDataAdapter.__init__\u001b[0;34m(self, x, y, sample_weights, sample_weight_modes, batch_size, epochs, steps, shuffle, **kwargs)\u001b[0m\n\u001b[1;32m 351\u001b[0m \u001b[39mreturn\u001b[39;00m flat_dataset\n\u001b[1;32m 353\u001b[0m indices_dataset \u001b[39m=\u001b[39m indices_dataset\u001b[39m.\u001b[39mflat_map(slice_batch_indices)\n\u001b[0;32m--> 355\u001b[0m dataset \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mslice_inputs(indices_dataset, inputs)\n\u001b[1;32m 357\u001b[0m \u001b[39mif\u001b[39;00m shuffle \u001b[39m==\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mbatch\u001b[39m\u001b[39m\"\u001b[39m:\n\u001b[1;32m 359\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mshuffle_batch\u001b[39m(\u001b[39m*\u001b[39mbatch):\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:396\u001b[0m, in \u001b[0;36mTensorLikeDataAdapter.slice_inputs\u001b[0;34m(self, indices_dataset, inputs)\u001b[0m\n\u001b[1;32m 391\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mgrab_batch\u001b[39m(i, data):\n\u001b[1;32m 392\u001b[0m \u001b[39mreturn\u001b[39;00m tf\u001b[39m.\u001b[39mnest\u001b[39m.\u001b[39mmap_structure(\n\u001b[1;32m 393\u001b[0m \u001b[39mlambda\u001b[39;00m d: tf\u001b[39m.\u001b[39mgather(d, i, axis\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m), data\n\u001b[1;32m 394\u001b[0m )\n\u001b[0;32m--> 396\u001b[0m dataset \u001b[39m=\u001b[39m dataset\u001b[39m.\u001b[39;49mmap(grab_batch, num_parallel_calls\u001b[39m=\u001b[39;49mtf\u001b[39m.\u001b[39;49mdata\u001b[39m.\u001b[39;49mAUTOTUNE)\n\u001b[1;32m 398\u001b[0m \u001b[39m# Default optimizations are disabled to avoid the overhead of\u001b[39;00m\n\u001b[1;32m 399\u001b[0m \u001b[39m# (unnecessary) input pipeline graph serialization and deserialization\u001b[39;00m\n\u001b[1;32m 400\u001b[0m options \u001b[39m=\u001b[39m tf\u001b[39m.\u001b[39mdata\u001b[39m.\u001b[39mOptions()\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/dataset_ops.py:2278\u001b[0m, in \u001b[0;36mDatasetV2.map\u001b[0;34m(self, map_func, num_parallel_calls, deterministic, name)\u001b[0m\n\u001b[1;32m 2274\u001b[0m \u001b[39m# Loaded lazily due to a circular dependency (dataset_ops -> map_op ->\u001b[39;00m\n\u001b[1;32m 2275\u001b[0m \u001b[39m# dataset_ops).\u001b[39;00m\n\u001b[1;32m 2276\u001b[0m \u001b[39m# pylint: disable=g-import-not-at-top,protected-access\u001b[39;00m\n\u001b[1;32m 2277\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mtensorflow\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mpython\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mdata\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mops\u001b[39;00m \u001b[39mimport\u001b[39;00m map_op\n\u001b[0;32m-> 2278\u001b[0m \u001b[39mreturn\u001b[39;00m map_op\u001b[39m.\u001b[39;49m_map_v2(\n\u001b[1;32m 2279\u001b[0m \u001b[39mself\u001b[39;49m,\n\u001b[1;32m 2280\u001b[0m map_func,\n\u001b[1;32m 2281\u001b[0m num_parallel_calls\u001b[39m=\u001b[39;49mnum_parallel_calls,\n\u001b[1;32m 2282\u001b[0m deterministic\u001b[39m=\u001b[39;49mdeterministic,\n\u001b[1;32m 2283\u001b[0m name\u001b[39m=\u001b[39;49mname)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/map_op.py:40\u001b[0m, in \u001b[0;36m_map_v2\u001b[0;34m(input_dataset, map_func, num_parallel_calls, deterministic, name)\u001b[0m\n\u001b[1;32m 37\u001b[0m \u001b[39mreturn\u001b[39;00m _MapDataset(\n\u001b[1;32m 38\u001b[0m input_dataset, map_func, preserve_cardinality\u001b[39m=\u001b[39m\u001b[39mTrue\u001b[39;00m, name\u001b[39m=\u001b[39mname)\n\u001b[1;32m 39\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[0;32m---> 40\u001b[0m \u001b[39mreturn\u001b[39;00m _ParallelMapDataset(\n\u001b[1;32m 41\u001b[0m input_dataset,\n\u001b[1;32m 42\u001b[0m map_func,\n\u001b[1;32m 43\u001b[0m num_parallel_calls\u001b[39m=\u001b[39;49mnum_parallel_calls,\n\u001b[1;32m 44\u001b[0m deterministic\u001b[39m=\u001b[39;49mdeterministic,\n\u001b[1;32m 45\u001b[0m preserve_cardinality\u001b[39m=\u001b[39;49m\u001b[39mTrue\u001b[39;49;00m,\n\u001b[1;32m 46\u001b[0m name\u001b[39m=\u001b[39;49mname)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/map_op.py:148\u001b[0m, in \u001b[0;36m_ParallelMapDataset.__init__\u001b[0;34m(self, input_dataset, map_func, num_parallel_calls, deterministic, use_inter_op_parallelism, preserve_cardinality, use_legacy_function, name)\u001b[0m\n\u001b[1;32m 146\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_input_dataset \u001b[39m=\u001b[39m input_dataset\n\u001b[1;32m 147\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_use_inter_op_parallelism \u001b[39m=\u001b[39m use_inter_op_parallelism\n\u001b[0;32m--> 148\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_map_func \u001b[39m=\u001b[39m structured_function\u001b[39m.\u001b[39;49mStructuredFunctionWrapper(\n\u001b[1;32m 149\u001b[0m map_func,\n\u001b[1;32m 150\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_transformation_name(),\n\u001b[1;32m 151\u001b[0m dataset\u001b[39m=\u001b[39;49minput_dataset,\n\u001b[1;32m 152\u001b[0m use_legacy_function\u001b[39m=\u001b[39;49muse_legacy_function)\n\u001b[1;32m 153\u001b[0m \u001b[39mif\u001b[39;00m deterministic \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 154\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_deterministic \u001b[39m=\u001b[39m \u001b[39m\"\u001b[39m\u001b[39mdefault\u001b[39m\u001b[39m\"\u001b[39m\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/structured_function.py:272\u001b[0m, in \u001b[0;36mStructuredFunctionWrapper.__init__\u001b[0;34m(self, func, transformation_name, dataset, input_classes, input_shapes, input_types, input_structure, add_to_graph, use_legacy_function, defun_kwargs)\u001b[0m\n\u001b[1;32m 265\u001b[0m warnings\u001b[39m.\u001b[39mwarn(\n\u001b[1;32m 266\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mEven though the `tf.config.experimental_run_functions_eagerly` \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 267\u001b[0m \u001b[39m\"\u001b[39m\u001b[39moption is set, this option does not apply to tf.data functions. \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 268\u001b[0m \u001b[39m\"\u001b[39m\u001b[39mTo force eager execution of tf.data functions, please use \u001b[39m\u001b[39m\"\u001b[39m\n\u001b[1;32m 269\u001b[0m \u001b[39m\"\u001b[39m\u001b[39m`tf.data.experimental.enable_debug_mode()`.\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 270\u001b[0m fn_factory \u001b[39m=\u001b[39m trace_tf_function(defun_kwargs)\n\u001b[0;32m--> 272\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_function \u001b[39m=\u001b[39m fn_factory()\n\u001b[1;32m 273\u001b[0m \u001b[39m# There is no graph to add in eager mode.\u001b[39;00m\n\u001b[1;32m 274\u001b[0m add_to_graph \u001b[39m&\u001b[39m\u001b[39m=\u001b[39m \u001b[39mnot\u001b[39;00m context\u001b[39m.\u001b[39mexecuting_eagerly()\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:1189\u001b[0m, in \u001b[0;36mFunction.get_concrete_function\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1187\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mget_concrete_function\u001b[39m(\u001b[39mself\u001b[39m, \u001b[39m*\u001b[39margs, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m 1188\u001b[0m \u001b[39m# Implements GenericFunction.get_concrete_function.\u001b[39;00m\n\u001b[0;32m-> 1189\u001b[0m concrete \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_get_concrete_function_garbage_collected(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 1190\u001b[0m concrete\u001b[39m.\u001b[39m_garbage_collector\u001b[39m.\u001b[39mrelease() \u001b[39m# pylint: disable=protected-access\u001b[39;00m\n\u001b[1;32m 1191\u001b[0m \u001b[39mreturn\u001b[39;00m concrete\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:1169\u001b[0m, in \u001b[0;36mFunction._get_concrete_function_garbage_collected\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1167\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_variable_creation_fn \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 1168\u001b[0m initializers \u001b[39m=\u001b[39m []\n\u001b[0;32m-> 1169\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_initialize(args, kwargs, add_initializers_to\u001b[39m=\u001b[39;49minitializers)\n\u001b[1;32m 1170\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_initialize_uninitialized_variables(initializers)\n\u001b[1;32m 1172\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_created_variables:\n\u001b[1;32m 1173\u001b[0m \u001b[39m# In this case we have created variables on the first call, so we run the\u001b[39;00m\n\u001b[1;32m 1174\u001b[0m \u001b[39m# version which is guaranteed to never create variables.\u001b[39;00m\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:694\u001b[0m, in \u001b[0;36mFunction._initialize\u001b[0;34m(self, args, kwds, add_initializers_to)\u001b[0m\n\u001b[1;32m 691\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_variable_creation_fn\u001b[39m.\u001b[39m_name \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_name \u001b[39m# pylint: disable=protected-access\u001b[39;00m\n\u001b[1;32m 692\u001b[0m \u001b[39m# Force the definition of the function for these arguments\u001b[39;00m\n\u001b[1;32m 693\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_concrete_variable_creation_fn \u001b[39m=\u001b[39m (\n\u001b[0;32m--> 694\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_variable_creation_fn \u001b[39m# pylint: disable=protected-access\u001b[39;49;00m\n\u001b[1;32m 695\u001b[0m \u001b[39m.\u001b[39;49m_get_concrete_function_internal_garbage_collected(\n\u001b[1;32m 696\u001b[0m \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwds))\n\u001b[1;32m 698\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39minvalid_creator_scope\u001b[39m(\u001b[39m*\u001b[39munused_args, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39munused_kwds):\n\u001b[1;32m 699\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Disables variable creation.\"\"\"\u001b[39;00m\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:176\u001b[0m, in \u001b[0;36mTracingCompiler._get_concrete_function_internal_garbage_collected\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 174\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Returns a concrete function which cleans up its graph function.\"\"\"\u001b[39;00m\n\u001b[1;32m 175\u001b[0m \u001b[39mwith\u001b[39;00m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_lock:\n\u001b[0;32m--> 176\u001b[0m concrete_function, _ \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_maybe_define_concrete_function(args, kwargs)\n\u001b[1;32m 177\u001b[0m \u001b[39mreturn\u001b[39;00m concrete_function\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:171\u001b[0m, in \u001b[0;36mTracingCompiler._maybe_define_concrete_function\u001b[0;34m(self, args, kwargs)\u001b[0m\n\u001b[1;32m 168\u001b[0m args \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39minput_signature\n\u001b[1;32m 169\u001b[0m kwargs \u001b[39m=\u001b[39m {}\n\u001b[0;32m--> 171\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_maybe_define_function(args, kwargs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:398\u001b[0m, in \u001b[0;36mTracingCompiler._maybe_define_function\u001b[0;34m(self, args, kwargs)\u001b[0m\n\u001b[1;32m 395\u001b[0m args \u001b[39m=\u001b[39m placeholder_bound_args\u001b[39m.\u001b[39margs\n\u001b[1;32m 396\u001b[0m kwargs \u001b[39m=\u001b[39m placeholder_bound_args\u001b[39m.\u001b[39mkwargs\n\u001b[0;32m--> 398\u001b[0m concrete_function \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_create_concrete_function(\n\u001b[1;32m 399\u001b[0m args, kwargs, func_graph)\n\u001b[1;32m 401\u001b[0m \u001b[39m# TODO(b/263520817): Remove access to private attribute.\u001b[39;00m\n\u001b[1;32m 402\u001b[0m graph_capture_container \u001b[39m=\u001b[39m concrete_function\u001b[39m.\u001b[39mgraph\u001b[39m.\u001b[39mfunction_captures\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/tracing_compiler.py:305\u001b[0m, in \u001b[0;36mTracingCompiler._create_concrete_function\u001b[0;34m(self, args, kwargs, func_graph)\u001b[0m\n\u001b[1;32m 301\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m 302\u001b[0m arg_names \u001b[39m=\u001b[39m base_arg_names\n\u001b[1;32m 304\u001b[0m concrete_function \u001b[39m=\u001b[39m monomorphic_function\u001b[39m.\u001b[39mConcreteFunction(\n\u001b[0;32m--> 305\u001b[0m func_graph_module\u001b[39m.\u001b[39;49mfunc_graph_from_py_func(\n\u001b[1;32m 306\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_name,\n\u001b[1;32m 307\u001b[0m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_python_function,\n\u001b[1;32m 308\u001b[0m args,\n\u001b[1;32m 309\u001b[0m kwargs,\n\u001b[1;32m 310\u001b[0m \u001b[39mNone\u001b[39;49;00m,\n\u001b[1;32m 311\u001b[0m func_graph\u001b[39m=\u001b[39;49mfunc_graph,\n\u001b[1;32m 312\u001b[0m arg_names\u001b[39m=\u001b[39;49marg_names,\n\u001b[1;32m 313\u001b[0m capture_by_value\u001b[39m=\u001b[39;49m\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_capture_by_value,\n\u001b[1;32m 314\u001b[0m create_placeholders\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m),\n\u001b[1;32m 315\u001b[0m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_function_attributes,\n\u001b[1;32m 316\u001b[0m spec\u001b[39m=\u001b[39m\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mfunction_spec,\n\u001b[1;32m 317\u001b[0m \u001b[39m# Tell the ConcreteFunction to clean up its graph once it goes out of\u001b[39;00m\n\u001b[1;32m 318\u001b[0m \u001b[39m# scope. This is not the default behavior since it gets used in some\u001b[39;00m\n\u001b[1;32m 319\u001b[0m \u001b[39m# places (like Keras) where the FuncGraph lives longer than the\u001b[39;00m\n\u001b[1;32m 320\u001b[0m \u001b[39m# ConcreteFunction.\u001b[39;00m\n\u001b[1;32m 321\u001b[0m shared_func_graph\u001b[39m=\u001b[39m\u001b[39mFalse\u001b[39;00m)\n\u001b[1;32m 322\u001b[0m \u001b[39mreturn\u001b[39;00m concrete_function\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/framework/func_graph.py:1055\u001b[0m, in \u001b[0;36mfunc_graph_from_py_func\u001b[0;34m(name, python_func, args, kwargs, signature, func_graph, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, create_placeholders)\u001b[0m\n\u001b[1;32m 1052\u001b[0m \u001b[39mreturn\u001b[39;00m x\n\u001b[1;32m 1054\u001b[0m _, original_func \u001b[39m=\u001b[39m tf_decorator\u001b[39m.\u001b[39munwrap(python_func)\n\u001b[0;32m-> 1055\u001b[0m func_outputs \u001b[39m=\u001b[39m python_func(\u001b[39m*\u001b[39;49mfunc_args, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mfunc_kwargs)\n\u001b[1;32m 1057\u001b[0m \u001b[39m# invariant: `func_outputs` contains only Tensors, CompositeTensors,\u001b[39;00m\n\u001b[1;32m 1058\u001b[0m \u001b[39m# TensorArrays and `None`s.\u001b[39;00m\n\u001b[1;32m 1059\u001b[0m func_outputs \u001b[39m=\u001b[39m variable_utils\u001b[39m.\u001b[39mconvert_variables_to_tensors(func_outputs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/eager/polymorphic_function/polymorphic_function.py:597\u001b[0m, in \u001b[0;36mFunction._compiler_with_scope.<locals>.wrapped_fn\u001b[0;34m(*args, **kwds)\u001b[0m\n\u001b[1;32m 593\u001b[0m \u001b[39mwith\u001b[39;00m default_graph\u001b[39m.\u001b[39m_variable_creator_scope(scope, priority\u001b[39m=\u001b[39m\u001b[39m50\u001b[39m): \u001b[39m# pylint: disable=protected-access\u001b[39;00m\n\u001b[1;32m 594\u001b[0m \u001b[39m# __wrapped__ allows AutoGraph to swap in a converted function. We give\u001b[39;00m\n\u001b[1;32m 595\u001b[0m \u001b[39m# the function a weak reference to itself to avoid a reference cycle.\u001b[39;00m\n\u001b[1;32m 596\u001b[0m \u001b[39mwith\u001b[39;00m OptionalXlaContext(compile_with_xla):\n\u001b[0;32m--> 597\u001b[0m out \u001b[39m=\u001b[39m weak_wrapped_fn()\u001b[39m.\u001b[39;49m__wrapped__(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwds)\n\u001b[1;32m 598\u001b[0m \u001b[39mreturn\u001b[39;00m out\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/structured_function.py:238\u001b[0m, in \u001b[0;36mStructuredFunctionWrapper.__init__.<locals>.trace_tf_function.<locals>.wrapped_fn\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m 237\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mwrapped_fn\u001b[39m(\u001b[39m*\u001b[39margs): \u001b[39m# pylint: disable=missing-docstring\u001b[39;00m\n\u001b[0;32m--> 238\u001b[0m ret \u001b[39m=\u001b[39m wrapper_helper(\u001b[39m*\u001b[39;49margs)\n\u001b[1;32m 239\u001b[0m ret \u001b[39m=\u001b[39m structure\u001b[39m.\u001b[39mto_tensor_list(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39m_output_structure, ret)\n\u001b[1;32m 240\u001b[0m \u001b[39mreturn\u001b[39;00m [ops\u001b[39m.\u001b[39mconvert_to_tensor(t) \u001b[39mfor\u001b[39;00m t \u001b[39min\u001b[39;00m ret]\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/data/ops/structured_function.py:168\u001b[0m, in \u001b[0;36mStructuredFunctionWrapper.__init__.<locals>.wrapper_helper\u001b[0;34m(*args)\u001b[0m\n\u001b[1;32m 166\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m _should_unpack(nested_args):\n\u001b[1;32m 167\u001b[0m nested_args \u001b[39m=\u001b[39m (nested_args,)\n\u001b[0;32m--> 168\u001b[0m ret \u001b[39m=\u001b[39m autograph\u001b[39m.\u001b[39;49mtf_convert(\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_func, ag_ctx)(\u001b[39m*\u001b[39;49mnested_args)\n\u001b[1;32m 169\u001b[0m ret \u001b[39m=\u001b[39m variable_utils\u001b[39m.\u001b[39mconvert_variables_to_tensors(ret)\n\u001b[1;32m 170\u001b[0m \u001b[39mif\u001b[39;00m _should_pack(ret):\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/autograph/impl/api.py:690\u001b[0m, in \u001b[0;36mconvert.<locals>.decorator.<locals>.wrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 688\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 689\u001b[0m \u001b[39mwith\u001b[39;00m conversion_ctx:\n\u001b[0;32m--> 690\u001b[0m \u001b[39mreturn\u001b[39;00m converted_call(f, args, kwargs, options\u001b[39m=\u001b[39;49moptions)\n\u001b[1;32m 691\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e: \u001b[39m# pylint:disable=broad-except\u001b[39;00m\n\u001b[1;32m 692\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mhasattr\u001b[39m(e, \u001b[39m'\u001b[39m\u001b[39mag_error_metadata\u001b[39m\u001b[39m'\u001b[39m):\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/autograph/impl/api.py:377\u001b[0m, in \u001b[0;36mconverted_call\u001b[0;34m(f, args, kwargs, caller_fn_scope, options)\u001b[0m\n\u001b[1;32m 374\u001b[0m \u001b[39mreturn\u001b[39;00m _call_unconverted(f, args, kwargs, options)\n\u001b[1;32m 376\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m options\u001b[39m.\u001b[39muser_requested \u001b[39mand\u001b[39;00m conversion\u001b[39m.\u001b[39mis_allowlisted(f):\n\u001b[0;32m--> 377\u001b[0m \u001b[39mreturn\u001b[39;00m _call_unconverted(f, args, kwargs, options)\n\u001b[1;32m 379\u001b[0m \u001b[39m# internal_convert_user_code is for example turned off when issuing a dynamic\u001b[39;00m\n\u001b[1;32m 380\u001b[0m \u001b[39m# call conversion from generated code while in nonrecursive mode. In that\u001b[39;00m\n\u001b[1;32m 381\u001b[0m \u001b[39m# case we evidently don't want to recurse, but we still have to convert\u001b[39;00m\n\u001b[1;32m 382\u001b[0m \u001b[39m# things like builtins.\u001b[39;00m\n\u001b[1;32m 383\u001b[0m \u001b[39mif\u001b[39;00m \u001b[39mnot\u001b[39;00m options\u001b[39m.\u001b[39minternal_convert_user_code:\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/autograph/impl/api.py:459\u001b[0m, in \u001b[0;36m_call_unconverted\u001b[0;34m(f, args, kwargs, options, update_cache)\u001b[0m\n\u001b[1;32m 456\u001b[0m \u001b[39mreturn\u001b[39;00m f\u001b[39m.\u001b[39m\u001b[39m__self__\u001b[39m\u001b[39m.\u001b[39mcall(args, kwargs)\n\u001b[1;32m 458\u001b[0m \u001b[39mif\u001b[39;00m kwargs \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m--> 459\u001b[0m \u001b[39mreturn\u001b[39;00m f(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 460\u001b[0m \u001b[39mreturn\u001b[39;00m f(\u001b[39m*\u001b[39margs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:392\u001b[0m, in \u001b[0;36mTensorLikeDataAdapter.slice_inputs.<locals>.grab_batch\u001b[0;34m(i, data)\u001b[0m\n\u001b[1;32m 391\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mgrab_batch\u001b[39m(i, data):\n\u001b[0;32m--> 392\u001b[0m \u001b[39mreturn\u001b[39;00m tf\u001b[39m.\u001b[39;49mnest\u001b[39m.\u001b[39;49mmap_structure(\n\u001b[1;32m 393\u001b[0m \u001b[39mlambda\u001b[39;49;00m d: tf\u001b[39m.\u001b[39;49mgather(d, i, axis\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m), data\n\u001b[1;32m 394\u001b[0m )\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/nest.py:624\u001b[0m, in \u001b[0;36mmap_structure\u001b[0;34m(func, *structure, **kwargs)\u001b[0m\n\u001b[1;32m 538\u001b[0m \u001b[39m@tf_export\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mnest.map_structure\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m 539\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mmap_structure\u001b[39m(func, \u001b[39m*\u001b[39mstructure, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs):\n\u001b[1;32m 540\u001b[0m \u001b[39m \u001b[39m\u001b[39m\"\"\"Creates a new structure by applying `func` to each atom in `structure`.\u001b[39;00m\n\u001b[1;32m 541\u001b[0m \n\u001b[1;32m 542\u001b[0m \u001b[39m Refer to [tf.nest](https://www.tensorflow.org/api_docs/python/tf/nest)\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 622\u001b[0m \u001b[39m ValueError: If wrong keyword arguments are provided.\u001b[39;00m\n\u001b[1;32m 623\u001b[0m \u001b[39m \"\"\"\u001b[39;00m\n\u001b[0;32m--> 624\u001b[0m \u001b[39mreturn\u001b[39;00m nest_util\u001b[39m.\u001b[39;49mmap_structure(\n\u001b[1;32m 625\u001b[0m nest_util\u001b[39m.\u001b[39;49mModality\u001b[39m.\u001b[39;49mCORE, func, \u001b[39m*\u001b[39;49mstructure, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs\n\u001b[1;32m 626\u001b[0m )\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/nest_util.py:1054\u001b[0m, in \u001b[0;36mmap_structure\u001b[0;34m(modality, func, *structure, **kwargs)\u001b[0m\n\u001b[1;32m 957\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Creates a new structure by applying `func` to each atom in `structure`.\u001b[39;00m\n\u001b[1;32m 958\u001b[0m \n\u001b[1;32m 959\u001b[0m \u001b[39m- For Modality.CORE: Refer to\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1051\u001b[0m \u001b[39m ValueError: If wrong keyword arguments are provided.\u001b[39;00m\n\u001b[1;32m 1052\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 1053\u001b[0m \u001b[39mif\u001b[39;00m modality \u001b[39m==\u001b[39m Modality\u001b[39m.\u001b[39mCORE:\n\u001b[0;32m-> 1054\u001b[0m \u001b[39mreturn\u001b[39;00m _tf_core_map_structure(func, \u001b[39m*\u001b[39;49mstructure, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 1055\u001b[0m \u001b[39melif\u001b[39;00m modality \u001b[39m==\u001b[39m Modality\u001b[39m.\u001b[39mDATA:\n\u001b[1;32m 1056\u001b[0m \u001b[39mreturn\u001b[39;00m _tf_data_map_structure(func, \u001b[39m*\u001b[39mstructure, \u001b[39m*\u001b[39m\u001b[39m*\u001b[39mkwargs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/nest_util.py:1094\u001b[0m, in \u001b[0;36m_tf_core_map_structure\u001b[0;34m(func, *structure, **kwargs)\u001b[0m\n\u001b[1;32m 1089\u001b[0m flat_structure \u001b[39m=\u001b[39m (_tf_core_flatten(s, expand_composites) \u001b[39mfor\u001b[39;00m s \u001b[39min\u001b[39;00m structure)\n\u001b[1;32m 1090\u001b[0m entries \u001b[39m=\u001b[39m \u001b[39mzip\u001b[39m(\u001b[39m*\u001b[39mflat_structure)\n\u001b[1;32m 1092\u001b[0m \u001b[39mreturn\u001b[39;00m _tf_core_pack_sequence_as(\n\u001b[1;32m 1093\u001b[0m structure[\u001b[39m0\u001b[39m],\n\u001b[0;32m-> 1094\u001b[0m [func(\u001b[39m*\u001b[39;49mx) \u001b[39mfor\u001b[39;49;00m x \u001b[39min\u001b[39;49;00m entries],\n\u001b[1;32m 1095\u001b[0m expand_composites\u001b[39m=\u001b[39mexpand_composites,\n\u001b[1;32m 1096\u001b[0m )\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/nest_util.py:1094\u001b[0m, in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 1089\u001b[0m flat_structure \u001b[39m=\u001b[39m (_tf_core_flatten(s, expand_composites) \u001b[39mfor\u001b[39;00m s \u001b[39min\u001b[39;00m structure)\n\u001b[1;32m 1090\u001b[0m entries \u001b[39m=\u001b[39m \u001b[39mzip\u001b[39m(\u001b[39m*\u001b[39mflat_structure)\n\u001b[1;32m 1092\u001b[0m \u001b[39mreturn\u001b[39;00m _tf_core_pack_sequence_as(\n\u001b[1;32m 1093\u001b[0m structure[\u001b[39m0\u001b[39m],\n\u001b[0;32m-> 1094\u001b[0m [func(\u001b[39m*\u001b[39;49mx) \u001b[39mfor\u001b[39;00m x \u001b[39min\u001b[39;00m entries],\n\u001b[1;32m 1095\u001b[0m expand_composites\u001b[39m=\u001b[39mexpand_composites,\n\u001b[1;32m 1096\u001b[0m )\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/keras/src/engine/data_adapter.py:393\u001b[0m, in \u001b[0;36mTensorLikeDataAdapter.slice_inputs.<locals>.grab_batch.<locals>.<lambda>\u001b[0;34m(d)\u001b[0m\n\u001b[1;32m 391\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mgrab_batch\u001b[39m(i, data):\n\u001b[1;32m 392\u001b[0m \u001b[39mreturn\u001b[39;00m tf\u001b[39m.\u001b[39mnest\u001b[39m.\u001b[39mmap_structure(\n\u001b[0;32m--> 393\u001b[0m \u001b[39mlambda\u001b[39;00m d: tf\u001b[39m.\u001b[39;49mgather(d, i, axis\u001b[39m=\u001b[39;49m\u001b[39m0\u001b[39;49m), data\n\u001b[1;32m 394\u001b[0m )\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/traceback_utils.py:150\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 148\u001b[0m filtered_tb \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 149\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 150\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 151\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 152\u001b[0m filtered_tb \u001b[39m=\u001b[39m _process_traceback_frames(e\u001b[39m.\u001b[39m__traceback__)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/dispatch.py:1176\u001b[0m, in \u001b[0;36madd_dispatch_support.<locals>.decorator.<locals>.op_dispatch_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[39m# Fallback dispatch system (dispatch v1):\u001b[39;00m\n\u001b[1;32m 1175\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 1176\u001b[0m \u001b[39mreturn\u001b[39;00m dispatch_target(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 1177\u001b[0m \u001b[39mexcept\u001b[39;00m (\u001b[39mTypeError\u001b[39;00m, \u001b[39mValueError\u001b[39;00m):\n\u001b[1;32m 1178\u001b[0m \u001b[39m# Note: convert_to_eager_tensor currently raises a ValueError, not a\u001b[39;00m\n\u001b[1;32m 1179\u001b[0m \u001b[39m# TypeError, when given unexpected types. So we need to catch both.\u001b[39;00m\n\u001b[1;32m 1180\u001b[0m result \u001b[39m=\u001b[39m dispatch(op_dispatch_handler, args, kwargs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/ops/array_ops.py:5149\u001b[0m, in \u001b[0;36mgather_v2\u001b[0;34m(params, indices, validate_indices, axis, batch_dims, name)\u001b[0m\n\u001b[1;32m 5141\u001b[0m \u001b[39m@tf_export\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mgather\u001b[39m\u001b[39m\"\u001b[39m, v1\u001b[39m=\u001b[39m[])\n\u001b[1;32m 5142\u001b[0m \u001b[39m@dispatch\u001b[39m\u001b[39m.\u001b[39madd_dispatch_support\n\u001b[1;32m 5143\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mgather_v2\u001b[39m(params,\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 5147\u001b[0m batch_dims\u001b[39m=\u001b[39m\u001b[39m0\u001b[39m,\n\u001b[1;32m 5148\u001b[0m name\u001b[39m=\u001b[39m\u001b[39mNone\u001b[39;00m):\n\u001b[0;32m-> 5149\u001b[0m \u001b[39mreturn\u001b[39;00m gather(\n\u001b[1;32m 5150\u001b[0m params,\n\u001b[1;32m 5151\u001b[0m indices,\n\u001b[1;32m 5152\u001b[0m validate_indices\u001b[39m=\u001b[39;49mvalidate_indices,\n\u001b[1;32m 5153\u001b[0m name\u001b[39m=\u001b[39;49mname,\n\u001b[1;32m 5154\u001b[0m axis\u001b[39m=\u001b[39;49maxis,\n\u001b[1;32m 5155\u001b[0m batch_dims\u001b[39m=\u001b[39;49mbatch_dims)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/traceback_utils.py:150\u001b[0m, in \u001b[0;36mfilter_traceback.<locals>.error_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 148\u001b[0m filtered_tb \u001b[39m=\u001b[39m \u001b[39mNone\u001b[39;00m\n\u001b[1;32m 149\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m--> 150\u001b[0m \u001b[39mreturn\u001b[39;00m fn(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 151\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m e:\n\u001b[1;32m 152\u001b[0m filtered_tb \u001b[39m=\u001b[39m _process_traceback_frames(e\u001b[39m.\u001b[39m__traceback__)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/dispatch.py:1176\u001b[0m, in \u001b[0;36madd_dispatch_support.<locals>.decorator.<locals>.op_dispatch_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 1174\u001b[0m \u001b[39m# Fallback dispatch system (dispatch v1):\u001b[39;00m\n\u001b[1;32m 1175\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[0;32m-> 1176\u001b[0m \u001b[39mreturn\u001b[39;00m dispatch_target(\u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 1177\u001b[0m \u001b[39mexcept\u001b[39;00m (\u001b[39mTypeError\u001b[39;00m, \u001b[39mValueError\u001b[39;00m):\n\u001b[1;32m 1178\u001b[0m \u001b[39m# Note: convert_to_eager_tensor currently raises a ValueError, not a\u001b[39;00m\n\u001b[1;32m 1179\u001b[0m \u001b[39m# TypeError, when given unexpected types. So we need to catch both.\u001b[39;00m\n\u001b[1;32m 1180\u001b[0m result \u001b[39m=\u001b[39m dispatch(op_dispatch_handler, args, kwargs)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/deprecation.py:549\u001b[0m, in \u001b[0;36mdeprecated_args.<locals>.deprecated_wrapper.<locals>.new_func\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 547\u001b[0m \u001b[39mif\u001b[39;00m is_in_graph_mode\u001b[39m.\u001b[39mIS_IN_GRAPH_MODE() \u001b[39mand\u001b[39;00m _PRINT_DEPRECATION_WARNINGS:\n\u001b[1;32m 548\u001b[0m invalid_args \u001b[39m=\u001b[39m []\n\u001b[0;32m--> 549\u001b[0m named_args \u001b[39m=\u001b[39m tf_inspect\u001b[39m.\u001b[39;49mgetcallargs(func, \u001b[39m*\u001b[39;49margs, \u001b[39m*\u001b[39;49m\u001b[39m*\u001b[39;49mkwargs)\n\u001b[1;32m 550\u001b[0m \u001b[39mfor\u001b[39;00m arg_name, spec \u001b[39min\u001b[39;00m \u001b[39miter\u001b[39m(deprecated_positions\u001b[39m.\u001b[39mitems()):\n\u001b[1;32m 551\u001b[0m \u001b[39mif\u001b[39;00m (spec\u001b[39m.\u001b[39mposition \u001b[39m<\u001b[39m \u001b[39mlen\u001b[39m(args) \u001b[39mand\u001b[39;00m\n\u001b[1;32m 552\u001b[0m \u001b[39mnot\u001b[39;00m (spec\u001b[39m.\u001b[39mhas_ok_value \u001b[39mand\u001b[39;00m\n\u001b[1;32m 553\u001b[0m _same_value(named_args[arg_name], spec\u001b[39m.\u001b[39mok_value))):\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/tf_inspect.py:307\u001b[0m, in \u001b[0;36mgetcallargs\u001b[0;34m(*func_and_positional, **named)\u001b[0m\n\u001b[1;32m 305\u001b[0m func \u001b[39m=\u001b[39m func_and_positional[\u001b[39m0\u001b[39m]\n\u001b[1;32m 306\u001b[0m positional \u001b[39m=\u001b[39m func_and_positional[\u001b[39m1\u001b[39m:]\n\u001b[0;32m--> 307\u001b[0m argspec \u001b[39m=\u001b[39m getfullargspec(func)\n\u001b[1;32m 308\u001b[0m call_args \u001b[39m=\u001b[39m named\u001b[39m.\u001b[39mcopy()\n\u001b[1;32m 309\u001b[0m this \u001b[39m=\u001b[39m \u001b[39mgetattr\u001b[39m(func, \u001b[39m'\u001b[39m\u001b[39mim_self\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m) \u001b[39mor\u001b[39;00m \u001b[39mgetattr\u001b[39m(func, \u001b[39m'\u001b[39m\u001b[39m__self__\u001b[39m\u001b[39m'\u001b[39m, \u001b[39mNone\u001b[39;00m)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/site-packages/tensorflow/python/util/tf_inspect.py:286\u001b[0m, in \u001b[0;36mgetfullargspec\u001b[0;34m(obj)\u001b[0m\n\u001b[1;32m 284\u001b[0m \u001b[39mif\u001b[39;00m d\u001b[39m.\u001b[39mdecorator_argspec \u001b[39mis\u001b[39;00m \u001b[39mnot\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[1;32m 285\u001b[0m \u001b[39mreturn\u001b[39;00m _convert_maybe_argspec_to_fullargspec(d\u001b[39m.\u001b[39mdecorator_argspec)\n\u001b[0;32m--> 286\u001b[0m \u001b[39mreturn\u001b[39;00m _getfullargspec(target)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/inspect.py:1369\u001b[0m, in \u001b[0;36mgetfullargspec\u001b[0;34m(func)\u001b[0m\n\u001b[1;32m 1337\u001b[0m \u001b[39m\u001b[39m\u001b[39m\"\"\"Get the names and default values of a callable object's parameters.\u001b[39;00m\n\u001b[1;32m 1338\u001b[0m \n\u001b[1;32m 1339\u001b[0m \u001b[39mA tuple of seven things is returned:\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1350\u001b[0m \u001b[39m - wrapper chains defined by __wrapped__ *not* unwrapped automatically\u001b[39;00m\n\u001b[1;32m 1351\u001b[0m \u001b[39m\"\"\"\u001b[39;00m\n\u001b[1;32m 1352\u001b[0m \u001b[39mtry\u001b[39;00m:\n\u001b[1;32m 1353\u001b[0m \u001b[39m# Re: `skip_bound_arg=False`\u001b[39;00m\n\u001b[1;32m 1354\u001b[0m \u001b[39m#\u001b[39;00m\n\u001b[0;32m (...)\u001b[0m\n\u001b[1;32m 1366\u001b[0m \u001b[39m# getfullargspec() historically ignored __wrapped__ attributes,\u001b[39;00m\n\u001b[1;32m 1367\u001b[0m \u001b[39m# so we ensure that remains the case in 3.3+\u001b[39;00m\n\u001b[0;32m-> 1369\u001b[0m sig \u001b[39m=\u001b[39m _signature_from_callable(func,\n\u001b[1;32m 1370\u001b[0m follow_wrapper_chains\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m,\n\u001b[1;32m 1371\u001b[0m skip_bound_arg\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m,\n\u001b[1;32m 1372\u001b[0m sigcls\u001b[39m=\u001b[39;49mSignature,\n\u001b[1;32m 1373\u001b[0m eval_str\u001b[39m=\u001b[39;49m\u001b[39mFalse\u001b[39;49;00m)\n\u001b[1;32m 1374\u001b[0m \u001b[39mexcept\u001b[39;00m \u001b[39mException\u001b[39;00m \u001b[39mas\u001b[39;00m ex:\n\u001b[1;32m 1375\u001b[0m \u001b[39m# Most of the times 'signature' will raise ValueError.\u001b[39;00m\n\u001b[1;32m 1376\u001b[0m \u001b[39m# But, it can also raise AttributeError, and, maybe something\u001b[39;00m\n\u001b[1;32m 1377\u001b[0m \u001b[39m# else. So to be fully backwards compatible, we catch all\u001b[39;00m\n\u001b[1;32m 1378\u001b[0m \u001b[39m# possible exceptions here, and reraise a TypeError.\u001b[39;00m\n\u001b[1;32m 1379\u001b[0m \u001b[39mraise\u001b[39;00m \u001b[39mTypeError\u001b[39;00m(\u001b[39m'\u001b[39m\u001b[39munsupported callable\u001b[39m\u001b[39m'\u001b[39m) \u001b[39mfrom\u001b[39;00m \u001b[39mex\u001b[39;00m\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/inspect.py:2516\u001b[0m, in \u001b[0;36m_signature_from_callable\u001b[0;34m(obj, follow_wrapper_chains, skip_bound_arg, globals, locals, eval_str, sigcls)\u001b[0m\n\u001b[1;32m 2511\u001b[0m \u001b[39mreturn\u001b[39;00m sig\u001b[39m.\u001b[39mreplace(parameters\u001b[39m=\u001b[39mnew_params)\n\u001b[1;32m 2513\u001b[0m \u001b[39mif\u001b[39;00m isfunction(obj) \u001b[39mor\u001b[39;00m _signature_is_functionlike(obj):\n\u001b[1;32m 2514\u001b[0m \u001b[39m# If it's a pure Python function, or an object that is duck type\u001b[39;00m\n\u001b[1;32m 2515\u001b[0m \u001b[39m# of a Python function (Cython functions, for instance), then:\u001b[39;00m\n\u001b[0;32m-> 2516\u001b[0m \u001b[39mreturn\u001b[39;00m _signature_from_function(sigcls, obj,\n\u001b[1;32m 2517\u001b[0m skip_bound_arg\u001b[39m=\u001b[39;49mskip_bound_arg,\n\u001b[1;32m 2518\u001b[0m \u001b[39mglobals\u001b[39;49m\u001b[39m=\u001b[39;49m\u001b[39mglobals\u001b[39;49m, \u001b[39mlocals\u001b[39;49m\u001b[39m=\u001b[39;49m\u001b[39mlocals\u001b[39;49m, eval_str\u001b[39m=\u001b[39;49meval_str)\n\u001b[1;32m 2520\u001b[0m \u001b[39mif\u001b[39;00m _signature_is_builtin(obj):\n\u001b[1;32m 2521\u001b[0m \u001b[39mreturn\u001b[39;00m _signature_from_builtin(sigcls, obj,\n\u001b[1;32m 2522\u001b[0m skip_bound_arg\u001b[39m=\u001b[39mskip_bound_arg)\n",
|
|
||||||
"File \u001b[0;32m~/.pyenv/versions/3.11.4/lib/python3.11/inspect.py:2386\u001b[0m, in \u001b[0;36m_signature_from_function\u001b[0;34m(cls, func, skip_bound_arg, globals, locals, eval_str)\u001b[0m\n\u001b[1;32m 2384\u001b[0m \u001b[39mfor\u001b[39;00m offset, name \u001b[39min\u001b[39;00m \u001b[39menumerate\u001b[39m(positional[non_default_count:]):\n\u001b[1;32m 2385\u001b[0m kind \u001b[39m=\u001b[39m _POSITIONAL_ONLY \u001b[39mif\u001b[39;00m posonly_left \u001b[39melse\u001b[39;00m _POSITIONAL_OR_KEYWORD\n\u001b[0;32m-> 2386\u001b[0m annotation \u001b[39m=\u001b[39m annotations\u001b[39m.\u001b[39mget(name, _empty)\n\u001b[1;32m 2387\u001b[0m parameters\u001b[39m.\u001b[39mappend(Parameter(name, annotation\u001b[39m=\u001b[39mannotation,\n\u001b[1;32m 2388\u001b[0m kind\u001b[39m=\u001b[39mkind,\n\u001b[1;32m 2389\u001b[0m default\u001b[39m=\u001b[39mdefaults[offset]))\n\u001b[1;32m 2390\u001b[0m \u001b[39mif\u001b[39;00m posonly_left:\n",
|
|
||||||
"\u001b[0;31mKeyboardInterrupt\u001b[0m: "
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"env = gym.make('CartPole-v1')\n",
|
"env = gym.make('CartPole-v1')\n",
|
||||||
"n_games = 20\n",
|
"n_games = 50\n",
|
||||||
"agent = Agent(gamma=0.99, epsilon=1.0, alpha=0.0005, input_dims=4, n_actions=2, mem_size=1000000, batch_size=64, epsilon_end=0.01)\n",
|
"agent = Agent(gamma=0.99, epsilon=1.0, alpha=0.0005, input_dims=4, n_actions=2, mem_size=1000000, batch_size=64, epsilon_end=0.01)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"scores = []\n",
|
"scores = []\n",
|
||||||
@ -550,7 +155,8 @@
|
|||||||
" observation, info = env.reset()\n",
|
" observation, info = env.reset()\n",
|
||||||
" while not done:\n",
|
" while not done:\n",
|
||||||
" action = agent.choose_action(observation)\n",
|
" action = agent.choose_action(observation)\n",
|
||||||
" observation_, reward, done, _, info = env.step(action)\n",
|
" observation_, reward, terminated, truncated, info = env.step(action)\n",
|
||||||
|
" done = terminated or truncated\n",
|
||||||
" score += reward\n",
|
" score += reward\n",
|
||||||
" agent.remember(observation, action, reward, observation_, done)\n",
|
" agent.remember(observation, action, reward, observation_, done)\n",
|
||||||
" observation = observation_\n",
|
" observation = observation_\n",
|
||||||
@ -560,63 +166,32 @@
|
|||||||
" scores.append(score)\n",
|
" scores.append(score)\n",
|
||||||
"\n",
|
"\n",
|
||||||
" avg_score = np.mean(scores[max(0, i-100):(i+1)])\n",
|
" avg_score = np.mean(scores[max(0, i-100):(i+1)])\n",
|
||||||
" print('episode ', i, 'score %.2f' % score, 'average score %.2f' % avg_score)\n",
|
" print(f\"episode={i}, {score=:0.2f}, {avg_score=:0.2f}, {terminated=}, {truncated=}\")\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"attachments": {},
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"### Aufgabe 3\n",
|
||||||
"\n",
|
"\n",
|
||||||
" if i % 10 == 0 and i > 0:\n",
|
"Ob _Exploration_ oder _Exploitation_ stärker gewichtet ist, bestimmt bei uns der Faktor _epsilon_.\n",
|
||||||
" agent.save_model()\n",
|
"Dieser beginnt bei 1, und wird bei jedem Training mit `epsilon_dec` multipliziert (und somit reduziert, bis\n",
|
||||||
"\n",
|
"zu einem Minimalwert). Dadurch wird unser Agent anfangs Aktionen öfters Aktionen wagen, die nicht\n",
|
||||||
"\n",
|
"optimal sind, aber dafür neue Zustände offenbaren. Durch Ausprobieren haben wir uns für einen Wert von `epsilon_dec = 0.98`\n",
|
||||||
"#10 episodes = 10s, 20 = 18s, ab 39 Episoden, läuft der Algo unendlich weiter (ggf. weil er die Stange dann balanciert?)\n"
|
"entschieden, da dieser gute Resultate lieferte."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": 9,
|
"execution_count": null,
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [
|
"outputs": [],
|
||||||
{
|
|
||||||
"data": {
|
|
||||||
"text/plain": [
|
|
||||||
"[15.0,\n",
|
|
||||||
" 13.0,\n",
|
|
||||||
" 14.0,\n",
|
|
||||||
" 13.0,\n",
|
|
||||||
" 15.0,\n",
|
|
||||||
" 47.0,\n",
|
|
||||||
" 13.0,\n",
|
|
||||||
" 15.0,\n",
|
|
||||||
" 15.0,\n",
|
|
||||||
" 11.0,\n",
|
|
||||||
" 9.0,\n",
|
|
||||||
" 9.0,\n",
|
|
||||||
" 10.0,\n",
|
|
||||||
" 22.0,\n",
|
|
||||||
" 42.0,\n",
|
|
||||||
" 12.0,\n",
|
|
||||||
" 32.0,\n",
|
|
||||||
" 22.0,\n",
|
|
||||||
" 18.0,\n",
|
|
||||||
" 13.0,\n",
|
|
||||||
" 38.0,\n",
|
|
||||||
" 88.0,\n",
|
|
||||||
" 86.0,\n",
|
|
||||||
" 109.0,\n",
|
|
||||||
" 30.0,\n",
|
|
||||||
" 186.0,\n",
|
|
||||||
" 242.0,\n",
|
|
||||||
" 160.0,\n",
|
|
||||||
" 116.0,\n",
|
|
||||||
" 138.0,\n",
|
|
||||||
" 164.0]"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"execution_count": 9,
|
|
||||||
"metadata": {},
|
|
||||||
"output_type": "execute_result"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
"source": [
|
||||||
"scores"
|
"import matplotlib.pyplot as plt\n",
|
||||||
|
"\n",
|
||||||
|
"plt.plot(scores)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -636,7 +211,7 @@
|
|||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.4"
|
"version": "3.10.1"
|
||||||
},
|
},
|
||||||
"orig_nbformat": 4,
|
"orig_nbformat": 4,
|
||||||
"vscode": {
|
"vscode": {
|
||||||
|
|||||||
Reference in New Issue
Block a user