forked from tensorflow/tfjs-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
95 lines (80 loc) · 2.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!--
Copyright 2018 Google LLC. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
-->
<!doctype html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../shared/tfjs-examples.css" />
</head>
<style>
#load-model-div {
margin-top: 10px;
margin-bottom: 10px;
}
#reset {
margin-left: 100px;
}
#show-q-values-div {
margin-top: 5px;
}
#game-status-div {
margin-top: 15px;
}
</style>
<body>
<div class='tfjs-example-container centered-container'>
<section class='title-area'>
<h1>TensorFlow.js Reinforcement Learning: Snake DQN</h1>
<p class='subtitle'>Deep Q-Network for the Snake Game</p>
</section>
<section>
<p class='section-head'>Description</p>
<p>
This page loads a trained Deep Q-Network (DQN) and use it to play the
snake game.
The training is done in Node.js using <a href="https://github.com/tensorflow/tfjs-node">tfjs-node</a>.
See <a href="https://github.com/tensorflow/tfjs-examples/blob/master/snake-dqn/train.js">train.js</a>.
</p>
</section>
<section>
<p class='section-head'>Algorithm</p>
<p>
A <a href="https://en.wikipedia.org/wiki/Q-learning#Variants">DQN</a> is trained to estimate the value of actions given the current game state.
The DQN is a 2D convolutional network. See <a href="https://github.com/tensorflow/tfjs-examples/blob/master/snake-dqn/dqn.js">dqn.js</a>.
The epsilon-greedy algorithm is used to balance exploration and exploitation during training.
</p>
</section>
<section>
<div id="load-model-div">
<button id="load-hosted-model" width="200px" disabled>Load hosted model</button>
</div>
<div>
<button id="auto-play-stop" disabled>Auto Play</button>
<button id="step" disabled>Step</button>
<button id="reset" disabled>Reset</button>
</div>
<div id="show-q-values-div">
<input type="checkbox" id="show-q-values" checked>
<span>Show Q-values</span>
</div>
<div id="game-status-div">
<span id="game-status">Game started.</span>
</div>
<div>
<canvas id="game-canvas" height="400px" width="400px"></canvas>
</div>
</section>
</div>
</body>
<script src="index.js"></script>