forked from tensorflow/tfjs-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
178 lines (164 loc) · 5.74 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!--
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" />
<title>TensorFlow.js: Date Conversion Through Attention</title>
</head>
<style>
.horizontal-sections {
display: inline-block;
vertical-align: top;
}
.date-label {
font-size: 18px;
font-family: monospace;
padding: 5px;
width: 300px;
display: block;
}
.hint {
font-size: 12px;
font-family: monospace;
}
.dates {
font-size: 24px;
font-family: monospace;
}
.date-input-output-section {
display: inline-block;
}
.attention-section {
margin-top: 8px;
}
#attention-heatmap {
width: 600px;
height: 360px;
border: 2px solid lightblue
}
#date-format-table {
font-size: 15px;
font-family: monospace;
text-align: left;
}
li {
padding-top: 1px;
padding-bottom: 2px;
text-decoration: underline;
color: blue;
}
#random-date {
margin-top: 10px;
padding-top: 5px;
padding-bottom: 5px;
}
.benchmark {
color: gray;
}
</style>
<body>
<div class='tfjs-example-container centered-container'>
<section class='title-area'>
<h1>TensorFlow.js: Date String Conversion</h1>
<p class='subtitle'>Solving a Sequence-to-Sequence Task Using LSTM and Attention</p>
</section>
<section>
<p class='section-head'>Description</p>
<p>
This example demonstrates the inference stage of using a sequence-to-sequence
model to convert a myriad of common date formats into the
<a href="https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates" target="_blank">
ISO 8601 date format
</a>
(i.e., YYYY-MM-DD). The list below shows examples of the supported input date
formats.
</p>
<p>
The model is based on
<a href="https://js.tensorflow.org/api/latest/#layers.lstm" target="_blank">LSTM</a>
and the
<a href="https://medium.com/syncedreview/a-brief-overview-of-attention-mechanism-13c578ba9129" target="_blank">
attention mechanism
</a>.
</p>
<p>
The training uses
<a href="https://github.com/tensorflow/tfjs-node">tfjs-node</a>
and runs in the backend Node.js environment. The training script
can be found
<a href="https://github.com/tensorflow/tfjs-examples/tree/master/date-conversion-attention/train.js">
here
</a>.
</p>
</section>
<section>
<p class='section-head'>Status</p>
<p>
<span id="status"></span>
</p>
</section>
<section>
<p class='section-head'>Support Date Formats</p>
<p>
<div id="date-format-table">
<div>Examples for supported formats (click to try):</div>
<ul>
<li><span class="input-date-example">23Jan2015</span></li>
<li><span class="input-date-example">012315</span></li>
<li><span class="input-date-example">01/23/15</span></li>
<li><span class="input-date-example">1/23/15</span></li>
<li><span class="input-date-example">01/23/2015</span></li>
<li><span class="input-date-example">1/23/2015</span></li>
<li><span class="input-date-example">23-01-2015</span></li>
<li><span class="input-date-example">23-1-2015</span></li>
<li><span class="input-date-example">JAN 23, 15</span></li>
<li><span class="input-date-example">Jan 23, 2015</span></li>
<li><span class="input-date-example">23.01.2015</span></li>
<li><span class="input-date-example">23.1.2015</span></li>
<li><span class="input-date-example">2015.01.23</span></li>
<li><span class="input-date-example">2015.1.23</span></li>
<li><span class="input-date-example">20150123</span></li>
<li><span class="input-date-example">2015/01/23</span></li>
<li><span class="input-date-example">2015-01-23</span></li>
<li><span class="input-date-example">2015-1-23</span></li>
<li><span class="input-date-example">23 JAN 2015</span></li>
</ul>
</table>
</p>
</section>
<div class="horizontal-sections">
<div class="horizontal-sections">
<div class="date-input-output-section">
<div class="date-label">Input date string:</div>
<input type="text" class="dates" id="input-date-string" value="JAN 20, 2001"></input>
</div>
<div class="hint">Press Enter to Refresh Conversion</div>
<button id="random-date">Random</button>
</div>
<div class="horizontal-sections">
<div class="date-input-output-section">
<div class="date-label">Output date string:</div>
<input type="text" class="dates" id="output-date-string" disabled="true"></input>
</div>
<div class="attention-section">
<div class="date-label">Attention matrix:</div>
<div id="attention-heatmap"></div>
</div>
</div>
</div>
</div>
</body>
<script src="index.js"></script>