-
Notifications
You must be signed in to change notification settings - Fork 0
/
homework-6.html
373 lines (321 loc) · 11.9 KB
/
homework-6.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Homework 6</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<meta name="title" content="Homework 6"/>
<meta name="generator" content="Org-mode"/>
<meta name="generated" content="2013-07-23 19:50:32 EDT"/>
<meta name="author" content="nil"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
<style type="text/css">
<!--/*--><![CDATA[/*><!--*/
html { font-family: Times, serif; font-size: 12pt; }
.title { text-align: center; }
.todo { color: red; }
.done { color: green; }
.tag { background-color: #add8e6; font-weight:normal }
.target { }
.timestamp { color: #bebebe; }
.timestamp-kwd { color: #5f9ea0; }
.right {margin-left:auto; margin-right:0px; text-align:right;}
.left {margin-left:0px; margin-right:auto; text-align:left;}
.center {margin-left:auto; margin-right:auto; text-align:center;}
p.verse { margin-left: 3% }
pre {
border: 1pt solid #AEBDCC;
background-color: #F3F5F7;
padding: 5pt;
font-family: courier, monospace;
font-size: 90%;
overflow:auto;
}
table { border-collapse: collapse; }
td, th { vertical-align: top; }
th.right { text-align:center; }
th.left { text-align:center; }
th.center { text-align:center; }
td.right { text-align:right; }
td.left { text-align:left; }
td.center { text-align:center; }
dt { font-weight: bold; }
div.figure { padding: 0.5em; }
div.figure p { text-align: center; }
div.inlinetask {
padding:10px;
border:2px solid gray;
margin:10px;
background: #ffffcc;
}
textarea { overflow-x: auto; }
.linenr { font-size:smaller }
.code-highlighted {background-color:#ffff00;}
.org-info-js_info-navigation { border-style:none; }
#org-info-js_console-label { font-size:10px; font-weight:bold;
white-space:nowrap; }
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
font-weight:bold; }
/*]]>*/-->
</style>
<link rel="stylesheet" href="css/worg.css" type="text/css" media="screen" />
<script type="text/javascript">
<!--/*--><![CDATA[/*><!--*/
function CodeHighlightOn(elem, id)
{
var target = document.getElementById(id);
if(null != target) {
elem.cacheClassElem = elem.className;
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
elem.className = "code-highlighted";
}
}
function CodeHighlightOff(elem, id)
{
var target = document.getElementById(id);
if(elem.cacheClassElem)
elem.className = elem.cacheClassElem;
if(elem.cacheClassTarget)
target.className = elem.cacheClassTarget;
}
/*]]>*///-->
</script>
<script type="text/javascript" src="MathJax/MathJax.js">
<!--/*--><![CDATA[/*><!--*/
MathJax.Hub.Config({
// Only one of the two following lines, depending on user settings
// First allows browser-native MathML display, second forces HTML/CSS
// config: ["MMLorHTML.js"], jax: ["input/TeX"],
jax: ["input/TeX", "output/HTML-CSS"],
extensions: ["tex2jax.js","TeX/AMSmath.js","TeX/AMSsymbols.js",
"TeX/noUndefined.js"],
tex2jax: {
inlineMath: [ ["\\(","\\)"] ],
displayMath: [ ['$$','$$'], ["\\[","\\]"], ["\\begin{displaymath}","\\end{displaymath}"] ],
skipTags: ["script","noscript","style","textarea","pre","code"],
ignoreClass: "tex2jax_ignore",
processEscapes: false,
processEnvironments: true,
preview: "TeX"
},
showProcessingMessages: true,
displayAlign: "center",
displayIndent: "2em",
"HTML-CSS": {
scale: 100,
availableFonts: ["STIX","TeX"],
preferredFont: "TeX",
webFont: "TeX",
imageFont: "TeX",
showMathMenu: true,
},
MMLorHTML: {
prefer: {
MSIE: "MML",
Firefox: "MML",
Opera: "HTML",
other: "HTML"
}
}
});
/*]]>*///-->
</script>
</head>
<body>
<div id="preamble">
<a href="index.html">Home</a>
<!-- Plupper Button -->
<div id="plupperButton" style="display: inline;"></div>
<!-- End of Plupper Button Code -->
</div>
<div id="content">
<h1 class="title">Homework 6</h1>
<div id="table-of-contents">
<h2>TOC</h2>
<div id="text-table-of-contents">
<ul>
<li><a href="#sec-1">Task 1 (30 pts)</a></li>
<li><a href="#sec-2">Task 2 (30 pts)</a></li>
<li><a href="#sec-3">Task 3 (20 pts)</a></li>
<li><a href="#sec-4">Task 4 (20 pts)</a></li>
<li><a href="#sec-5">Extra credit 1 (60 pts)</a></li>
<li><a href="#sec-6">Extra credit 2 (20 pts)</a></li>
</ul>
</div>
</div>
<div id="outline-container-1" class="outline-2">
<h2 id="sec-1">Task 1 (30 pts)</h2>
<div class="outline-text-2" id="text-1">
<p>
Draw a single perceptron that computes the NOR (not-OR) function.
</p>
<p>
Be sure to give the weights of the two inputs and the bias
term. Assume the threshold function is that demonstrated in the
lecture notes (where a sum \(\geq 0.5\) causes a \(1\) to be output,
otherwise a \(0\)).
</p>
</div>
</div>
<div id="outline-container-2" class="outline-2">
<h2 id="sec-2">Task 2 (30 pts)</h2>
<div class="outline-text-2" id="text-2">
<p>
Draw a small perceptron network that computes addition of two one-bit
numbers. This cannot be done with only one perceptron. Here is the
table of inputs/outputs:
</p>
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
<caption></caption>
<colgroup><col class="right" /><col class="right" /><col class="right" /><col class="right" />
</colgroup>
<thead>
<tr><th scope="col" class="right">\(x_1\)</th><th scope="col" class="right">\(x_2\)</th><th scope="col" class="right">out 1</th><th scope="col" class="right">out 2 (carry bit)</th></tr>
</thead>
<tbody>
<tr><td class="right">0</td><td class="right">0</td><td class="right">0</td><td class="right">0</td></tr>
<tr><td class="right">0</td><td class="right">1</td><td class="right">1</td><td class="right">0</td></tr>
<tr><td class="right">1</td><td class="right">0</td><td class="right">1</td><td class="right">0</td></tr>
<tr><td class="right">1</td><td class="right">1</td><td class="right">0</td><td class="right">1</td></tr>
</tbody>
</table>
<p>
Use this perceptron configuration. Determine all the weights.
</p>
<div style="text-align: center">
<p><img src="./images/bitsum-perceptron.png" alt="./images/bitsum-perceptron.png" />
</p>
</div>
</div>
</div>
<div id="outline-container-3" class="outline-2">
<h2 id="sec-3">Task 3 (20 pts)</h2>
<div class="outline-text-2" id="text-3">
<p>
Find a dataset to load into Weka, and evaluate a MultilayerPerceptron
(in the “functions” category). Compare its performance to naïve
Bayesian and k-nn.
</p>
</div>
</div>
<div id="outline-container-4" class="outline-2">
<h2 id="sec-4">Task 4 (20 pts)</h2>
<div class="outline-text-2" id="text-4">
<p>
These are Asimov’s “Three Laws of Robotics”:
</p>
<ol>
<li>A robot may not injure a human being or, through inaction, allow a
human being to come to harm.
</li>
<li>A robot must obey the orders given to it by human beings, except
where such orders would conflict with the First Law.
</li>
<li>A robot must protect its own existence as long as such protection
does not conflict with the First or Second Laws.
</li>
</ol>
<p>
Give your opinion about whether these are good “laws,” how they might
be improved, and whether we could build systems that respect
them. (1 paragraph)
</p>
</div>
</div>
<div id="outline-container-5" class="outline-2">
<h2 id="sec-5">Extra credit 1 (60 pts)</h2>
<div class="outline-text-2" id="text-5">
<p>
Write a single-layer <i>logistic</i> perceptron network. Use the logistic
perceptron learning rule from the lecture notes. Report the “loss”
after each epoch. Divide the input file into an initial 90% for
training, the latter 10% for testing. (The input file has already been
shuffled.)
</p>
<p>
The input file is specified on the command line. Its format is:
</p>
<pre class="example">5620 64 10
0 0 0.0625 0.875 0.375 0 0 0 0 0 0.375 0.9375 ... 1 0 0 0 0 0 0 0 0 0
0 0 0 0 0.5625 1 0.25 0 0 0 0 0.3125 0.9375 1 ... 0 0 0 0 0 0 0 0 0 1
0 0.0625 0.375 0.9375 0.75 0.0625 0 0 0 0.4375 ... 0 1 0 0 0 0 0 0 0 0
</pre>
<p>
The first number, 5620, is the number of examples in the file, with
one example per line, starting on the second line. The second number,
64, is the number of inputs (or “features”) for each example; the
inputs are floating-point values. The third number, 10, is the number
of <i>binary</i> outputs for each example.
</p>
<p>
The input file (partially) shown here is from the <a href="./optdigits.dat">optdigits.dat</a>
(handwritten digits) input file (from <a href="http://archive.ics.uci.edu/ml/datasets/Optical+Recognition+of+Handwritten+Digits">UCI</a>). Each example has 64 floats
(integer values 0-16 divided by 16.0 to get values in the range [0,1])
followed by 10 binary numbers (0/1), such that the only 1 in this
group of binary numbers is in the position N, and this N is the true
digit of the example. So if the example is the digit 2, then the
binary numbers are: “0 0 1 0 0 0 0 0 0 0 0” (first binary number
indicates digit 0, then 1, then 2, etc.).
</p>
<p>
I have written templates for you to start with: <a href="./perceptron-template.cpp">C++</a>, <a href="./PerceptronTemplate.java">Java</a>, and
<a href="./perceptron_template.py">Python</a>. (Words of wisdom: Python is horrendously slow; my experiments
with this assignment show it to be 30 times slower than Java.) These
templates load the data file, build the data structures, and print the
weights of the trained network. You need to build the network, train
it, and finish the code that tests reserved instances from the input
file.
</p>
<p>
You can also test, for debugging purposes, the <a href="./and.dat">and.dat</a>, <a href="./or.dat">or.dat</a>, and
<a href="./not.dat">not.dat</a> cases. The primary test case for your code will be the
<a href="./optdigits.dat">optdigits.dat</a> file.
</p>
</div>
</div>
<div id="outline-container-6" class="outline-2">
<h2 id="sec-6">Extra credit 2 (20 pts)</h2>
<div class="outline-text-2" id="text-6">
<p>
Train your neural net with a different dataset you find on the
web. Tell me about the dataset (its inputs and outputs) and describe
the performance of your neural net.
</p>
<div style="font-size: 80%; clear: both;"> <span
xmlns:dct="http://purl.org/dc/terms/"
href="http://purl.org/dc/dcmitype/Text" property="dct:title"
rel="dct:type">AI Su13 material</span> by <a
xmlns:cc="http://creativecommons.org/ns#"
href="http://ai-su13.artifice.cc" property="cc:attributionName"
rel="cc:attributionURL">Joshua Eckroth</a> is licensed under a <a
rel="license"
href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
Attribution-ShareAlike 3.0 Unported License</a>. Source code for this
website available at <a
href="https://github.com/joshuaeckroth/ai-su13-website">GitHub</a>.
</div>
<!-- Plupper Tracking Code -->
<script src="https://www.google.com/jsapi"></script>
<script type="text/javascript"
src="https://static.plupper.com/js/plupper.js"></script>
<script type="text/javascript">
plupper.init("joshuaeckroth@plupper.com");
plupper.enableCobrowsing();
</script>
<!-- End of Plupper Tracking Code -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript">
$('.hidden .hidden-content').hide();
$('.hidden > strong').click(function() {
$(this).parent().find('.hidden-content').toggle();
});
</script>
</div>
</div>
</div>
</body>
</html>