Skip to content

Commit 7a66bbb

Browse files
committed
add assets
1 parent c524056 commit 7a66bbb

File tree

39 files changed

+666
-66
lines changed

39 files changed

+666
-66
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import gym\n",
10+
"from dqn_and_ddqn import agent"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"# Training on 4 environments\n",
20+
"environment_list = [\"CartPole-v0\",\"CartPole-v1\",\"Acrobot-v1\",\"MountainCar-v0\"]\n",
21+
"agent_names = [\"dqn\",\"ddqn\"]\n",
22+
"for env in environment_list:\n",
23+
" environment = gym.make(env)\n",
24+
" player = agent.Gameagent(environment=environment)\n",
25+
" for game_agent in agent_names:\n",
26+
" if(game_agent == \"dqn\"):\n",
27+
" train_steps,train_losses,train_rewards = player.train_dqn()\n",
28+
" else:\n",
29+
" train_steps,train_losses,train_rewards = player.train_ddqn()\n",
30+
" player.save_training_variable(game_agent,train_steps,train_losses,train_rewards)\n",
31+
" player.save_weights(game_agent)"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 3,
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"environment = gym.make(\"CartPole-v0\")"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 4,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"player = agent.Gameagent(environment=environment)"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 5,
55+
"metadata": {},
56+
"outputs": [
57+
{
58+
"name": "stdout",
59+
"output_type": "stream",
60+
"text": [
61+
"WARNING:tensorflow:Layer qnetwork is casting an input tensor from dtype float64 to the layer's dtype of float32, which is new behavior in TensorFlow 2. The layer has dtype float32 because it's dtype defaults to floatx.\n",
62+
"\n",
63+
"If you intended to run this layer in float32, you can safely ignore this warning. If in doubt, this warning is likely only an issue if you are porting a TensorFlow 1.X model to TensorFlow 2.\n",
64+
"\n",
65+
"To change all layers to have dtype float64 by default, call `tf.keras.backend.set_floatx('float64')`. To change just this layer, pass dtype='float64' to the layer constructor. If you are the author of this layer, you can disable autocasting by passing autocast=False to the base Layer constructor.\n",
66+
"\n",
67+
"Episode: 0, Episode Reward: 15, Episode Loss: 0.649, Epsilon: 0.99211159568869\n"
68+
]
69+
}
70+
],
71+
"source": [
72+
"## Loading weight must run once the model as suggested here https://www.tensorflow.org/guide/keras/save_and_serialize\n",
73+
"player.load_weights(\"dqn\") "
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {},
80+
"outputs": [],
81+
"source": []
82+
}
83+
],
84+
"metadata": {
85+
"kernelspec": {
86+
"display_name": "Python 3",
87+
"language": "python",
88+
"name": "python3"
89+
},
90+
"language_info": {
91+
"codemirror_mode": {
92+
"name": "ipython",
93+
"version": 3
94+
},
95+
"file_extension": ".py",
96+
"mimetype": "text/x-python",
97+
"name": "python",
98+
"nbconvert_exporter": "python",
99+
"pygments_lexer": "ipython3",
100+
"version": "3.7.4"
101+
}
102+
},
103+
"nbformat": 4,
104+
"nbformat_minor": 4
105+
}

Runner.ipynb

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [],
8+
"source": [
9+
"import gym\n",
10+
"from dqn_and_ddqn import agent"
11+
]
12+
},
13+
{
14+
"cell_type": "code",
15+
"execution_count": null,
16+
"metadata": {},
17+
"outputs": [],
18+
"source": [
19+
"# Training on 4 environments\n",
20+
"environment_list = [\"CartPole-v0\",\"CartPole-v1\",\"Acrobot-v1\",\"MountainCar-v0\"]\n",
21+
"agent_names = [\"dqn\",\"ddqn\"]\n",
22+
"for env in environment_list:\n",
23+
" environment = gym.make(env)\n",
24+
" player = agent.Gameagent(environment=environment)\n",
25+
" for game_agent in agent_names:\n",
26+
" if(game_agent == \"dqn\"):\n",
27+
" train_steps,train_losses,train_rewards = player.train_dqn()\n",
28+
" else:\n",
29+
" train_steps,train_losses,train_rewards = player.train_ddqn()\n",
30+
" player.save_training_variable(game_agent,train_steps,train_losses,train_rewards)\n",
31+
" player.save_weights(game_agent)"
32+
]
33+
},
34+
{
35+
"cell_type": "code",
36+
"execution_count": 3,
37+
"metadata": {},
38+
"outputs": [],
39+
"source": [
40+
"environment = gym.make(\"CartPole-v0\")"
41+
]
42+
},
43+
{
44+
"cell_type": "code",
45+
"execution_count": 4,
46+
"metadata": {},
47+
"outputs": [],
48+
"source": [
49+
"player = agent.Gameagent(environment=environment)"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 5,
55+
"metadata": {},
56+
"outputs": [
57+
{
58+
"name": "stdout",
59+
"output_type": "stream",
60+
"text": [
61+
"WARNING:tensorflow:Layer qnetwork is casting an input tensor from dtype float64 to the layer's dtype of float32, which is new behavior in TensorFlow 2. The layer has dtype float32 because it's dtype defaults to floatx.\n",
62+
"\n",
63+
"If you intended to run this layer in float32, you can safely ignore this warning. If in doubt, this warning is likely only an issue if you are porting a TensorFlow 1.X model to TensorFlow 2.\n",
64+
"\n",
65+
"To change all layers to have dtype float64 by default, call `tf.keras.backend.set_floatx('float64')`. To change just this layer, pass dtype='float64' to the layer constructor. If you are the author of this layer, you can disable autocasting by passing autocast=False to the base Layer constructor.\n",
66+
"\n",
67+
"Episode: 0, Episode Reward: 15, Episode Loss: 0.649, Epsilon: 0.99211159568869\n"
68+
]
69+
}
70+
],
71+
"source": [
72+
"## Loading weight must run once the model as suggested here https://www.tensorflow.org/guide/keras/save_and_serialize\n",
73+
"player.load_weights(\"dqn\") "
74+
]
75+
},
76+
{
77+
"cell_type": "code",
78+
"execution_count": null,
79+
"metadata": {},
80+
"outputs": [],
81+
"source": []
82+
}
83+
],
84+
"metadata": {
85+
"kernelspec": {
86+
"display_name": "Python 3",
87+
"language": "python",
88+
"name": "python3"
89+
},
90+
"language_info": {
91+
"codemirror_mode": {
92+
"name": "ipython",
93+
"version": 3
94+
},
95+
"file_extension": ".py",
96+
"mimetype": "text/x-python",
97+
"name": "python",
98+
"nbconvert_exporter": "python",
99+
"pygments_lexer": "ipython3",
100+
"version": "3.7.4"
101+
}
102+
},
103+
"nbformat": 4,
104+
"nbformat_minor": 4
105+
}
1.3 KB
Binary file not shown.
2.47 KB
Binary file not shown.
1.3 KB
Binary file not shown.
19.8 KB
Binary file not shown.
1.3 KB
Binary file not shown.
2.47 KB
Binary file not shown.
1.3 KB
Binary file not shown.
19.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)