⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hw97.ps

📁 Mitchell的《机器学习〉随书源码
💻 PS
📖 第 1 页 / 共 5 页
字号:
943 2322 V 16 w(<scale>.pgm)73 2461 y Ff(\017)24 b Fg(<userid>)14b Fh(is)i(the)g(user)h(id)f(of)h(the)f(p)q(erson)h(in)f(the)h(image,)d(and)j(this)g(\014eld)f(has)h(20)g(v)m(alues:)22 b(an2i,)1222522 y(at33,)d(b)q(oland,)g(bpm,)e(c)o(h4f,)g(c)o(hey)o(er,)g(c)o(ho)q(on,)h(danieln,)g(glic)o(kman,)d(k)m(ary)o(adi,)j(k)m(a)o(w)o(am)o(ura,)f(kk49,)122 2582 y(megak,)e(mitc)o(hel)o(l,)e(nigh)o(t,)i(pho)q(eb)q(e,)i(saa)o(vik,)e(ste\016,)h(sz24,)g(and)h(tammo.)732680 y Ff(\017)24 b Fg(<pose>)17 b Fh(is)i(the)f(head)i(p)q(osition)f(of)h(the)f(p)q(erson,)h(and)f(this)g(\014eld)g(has)g(4)h(v)m(alues:)27b(straigh)o(t,)19 b(left,)122 2740 y(righ)o(t,)c(up.)9612844 y(1)p eop%%Page: 2 22 1 bop 73 50 a Ff(\017)24 b Fg(<expressio)o(n>)8 b Fh(is)k(the)g(facial)f(expression)h(of)g(the)g(p)q(erson,)h(and)f(this)g(\014eld)g(has)g(4)h(v)m(alues:)19 b(neutral,)122 110 y(happ)o(y)l(,)d(sad,)g(angry)l(.)73 212 y Ff(\017)24 b Fg(<eyes>)14 b Fh(is)i(the)g(ey)o(e)f(state)i(of)f(the)g(p)q(erson,)h(and)g(this)f(\014eld)f(has)i(2)g(v)m(alues:)k(op)q(en,)c(sunglasses.)73 313 y Ff(\017)24b Fg(<scale>)14 b Fh(is)i(the)h(scale)f(of)h(the)f(image,)f(and)i(this)f(\014eld)g(has)i(3)f(v)m(alues:)22 b(1,)16 b(2,)h(and)g(4.)23b(1)17 b(indicates)122 374 y(a)h(full-resolution)e(image)g(\(128)j(columns)d Ff(\002)h Fh(120)i(ro)o(ws\);)f(2)f(indicates)g(a)h(half-resolution)f(image)122 434 y(\(64)c Ff(\002)e Fh(60\);)19b(4)f(indicates)f(a)h(quarter-resolution)g(image)e(\(32)dFf(\002)e Fh(30\).)26 b(F)l(or)18 b(this)g(assignmen)o(t,)e(y)o(ou)122494 y(will)e(b)q(e)h(using)h(the)f(quarter-resolution)g(images)f(for)i(exp)q(erimen)o(ts,)c(to)k(k)o(eep)e(training)h(time)e(to)i(a)122554 y(manageable)g(lev)o(el.)62 710 y(If)h(y)o(ou'v)o(e)e(b)q(een)i(lo)q(oking)h(closely)e(in)h(the)f(image)g(directories,)g(y)o(ou)h(ma)o(y)e(notice)h(that)i(some)e(images)0 770 y(ha)o(v)o(e)h(a)iFg(.bad)d Fh(su\016x)i(rather)g(than)h(the)e Fg(.pgm)gFh(su\016x.)23 b(As)17 b(it)g(turns)g(out,)g(16)h(of)f(the)g(640)h(images)e(tak)o(en)0 830 y(ha)o(v)o(e)21 b(glitc)o(hes)f(due)i(to)g(problems)e(with)i(the)f(camera)g(setup;)j(these)d(are)h(the)fFg(.bad)g Fh(images.)36 b(Some)0 890 y(p)q(eople)15 b(had)h(more)e(glitc)o(hes)g(than)i(others,)g(but)f(ev)o(ery)o(one)f(who)i(got)g(\\faced")g(should)g(ha)o(v)o(e)e(at)i(least)f(28)0 951y(go)q(o)q(d)j(face)e(images)f(\(out)i(of)g(the)f(32)h(v)m(ariations)f(p)q(ossible,)g(discoun)o(ting)g(scale\).)0 1122 y Fi(1.2.)55b(Viewing)19 b(the)f(face)g(images)0 1256 y Fh(T)l(o)g(view)e(the)h(images,)f(y)o(ou)i(can)f(use)g(the)g(program)h Fg(xv)pFh(.)23 b(This)18 b(is)f(a)o(v)m(ailable)f(as)i Fg(/usr/local)o(/bi)o(n/x)o(v)0 1316 y Fh(on)f(Andrew)f(mac)o(hines,)e(and)jFg(/usr/misc/.)o(X1)o(1-o)o(the)o(rs/)o(bi)o(n/x)o(v)cFh(or)k Fg(/usr/local/)o(bin)o(/x)o(v)d Fh(on)j(CS)01376 y(mac)o(hines.)25 b Fg(xv)17 b Fh(handles)i(a)f(v)m(ariet)o(y)f(of)i(image)e(formats,)g(including)h(the)f(PGM)i(format)e(in)h(whic)o(h)f(our)0 1436 y(face)i(images)e(are)i(stored.)30 b(While)18b(w)o(e)g(w)o(on't)h(go)g(in)o(to)g(detail)f(ab)q(out)iFg(xv)f Fh(in)f(this)h(do)q(cumen)o(t,)f(w)o(e)g(will)01497 y(quic)o(kly)c(describ)q(e)i(the)g(basics)g(y)o(ou)g(need)g(to)h(kno)o(w)f(to)h(use)f Fg(xv)p Fh(.)62 1598 y(T)l(o)h(start)gFg(xv)p Fh(,)e(just)h(sp)q(ecify)g(one)g(or)h(more)e(images)g(on)i(the)f(command)e(line,)h(lik)o(e)f(this:)62 1700 y Fg(xv)25b(/afs/cs/pr)o(oje)o(ct/)o(the)o(o-)o(8/f)o(ace)o(ima)o(ge)o(s/f)o(ace)o(s/)o(gli)o(ckm)o(an/)o(gl)o(ick)o(man)p 1606 1700 162 v 15 w(straight)p 1830 1700 V 15 w(happy)p 1975 1700V 17 w(open)p 2096 1700 V 17 w(4.pgm)62 1802 y Fh(This)c(will)f(bring)h(up)g(an)g(X)f(windo)o(w)h(displa)o(ying)f(the)h(face.)34b(Clic)o(king)19 b(the)i(righ)o(t)f(button)i(in)e(the)01862 y(image)d(windo)o(w)h(will)e(toggle)j(a)f(con)o(trol)g(panel)f(with)h(a)g(v)m(ariet)o(y)f(of)h(buttons.)27 b(The)18b Fg(Dbl)25 b(Size)16 b Fh(button)0 1922 y(doubles)j(the)g(displa)o(y)o(ed)f(size)g(of)i(the)e(image)g(ev)o(ery)g(time)f(y)o(ou)i(clic)o(k)e(on)i(it.)30 b(This)19 b(will)f(b)q(e)h(useful)g(for)01982 y(viewing)c(the)h(quarter-resolution)h(images,)d(as)j(y)o(ou)f(migh)o(t)f(imagine.)62 2084 y(Y)l(ou)e(can)g(also)h(obtain)f(pixel)e(v)m(alues)i(b)o(y)g(holding)g(do)o(wn)g(the)g(left)f(button)h(while)f(mo)o(ving)f(the)i(p)q(oin)o(ter)0 2144 y(in)j(the)g(image)f(windo)o(w.)22 b(A)16 b(text)g(bar)g(will)g(b)q(e)g(displa)o(y)o(ed,)f(sho)o(wing)i(y)o(ou)f(the)g(image)f(co)q(ordinates)i(and)02204 y(brigh)o(tness)f(v)m(alue)g(where)g(the)g(p)q(oin)o(ter)g(is)g(lo)q(cated.)62 2306 y(T)l(o)h(quit)f Fg(xv)p Fh(,)f(just)h(clic)o(k)e(on)j(the)f Fg(Quit)f Fh(button)i(or)f(t)o(yp)q(e)g Fg(q)gFh(in)g(one)g(of)h(the)f Fg(xv)f Fh(windo)o(ws.)0 2478y Fi(1.3.)55 b(The)19 b(neural)f(net)n(w)n(ork)h(and)g(image)e(access)h(co)r(de)0 2611 y Fh(W)l(e're)e(supplying)g(C)h(co)q(de)g(for)g(a)g(three-la)o(y)o(er)e(fully-connected)g(feedforw)o(ard)i(neural)f(net)o(w)o(ork)h(whic)o(h)0 2672 y(uses)j(the)f(bac)o(kpropagation)h(algorithm)f(to)h(tune)f(its)g(w)o(eigh)o(ts.)30 b(T)l(o)20b(mak)o(e)e(life)g(as)i(easy)f(as)h(p)q(ossible,)0 2732y(w)o(e're)14 b(also)i(supplying)e(y)o(ou)h(with)g(an)h(image)e(pac)o(k)m(age)h(for)h(accessing)f(the)f(face)h(images,)f(as)i(w)o(ell)d(as)j(the)961 2844 y(2)p eop%%Page: 3 33 2 bop 0 50 a Fh(top-lev)o(el)15 b(program)h(for)h(training)f(and)h(testing,)f(as)h(a)g(sk)o(eleton)f(for)g(y)o(ou)h(to)g(mo)q(dify)l(.)j(T)l(o)d(help)f(explore)0 110 y(what)k(the)g(nets)f(actually)g(learn,)h(y)o(ou'll)e(also)j(\014nd)f(a)g(utilit)o(y)d(program)j(for)g(visualizing)e(hidden-unit)0 170 y(w)o(eigh)o(ts)e(as)h(images.)62272 y(The)c(co)q(de)h(is)f(lo)q(cated)g(in)g Fg(/afs/cs/p)o(roj)o(ect)o(/th)o(eo)o(-8/)o(fac)o(eim)o(ag)o(es/)o(cod)o(e)p Fh(.)k(Cop)o(y)c(all)g(of)g(the)g(\014les)0 332 y(in)18 b(this)g(area)h(to)g(y)o(our)f(o)o(wn)g(directory)l(,)g(and)h(t)o(yp)q(e)f Fg(make)pFh(.)26 b(Note:)f(tak)o(e)17 b(care)h(to)h(use)f Fg(cp)25b(*)18 b Fh(instead)h(of)0 392 y Fg(cp)25 b(*.*)17 bFh(in)h(order)g(to)g(ensure)g(that)g(y)o(ou)g(get)g(the)gFg(Makefile)p Fh(.)24 b(When)18 b(the)g(compilation)e(is)i(done,)g(y)o(ou)0 452 y(should)i(ha)o(v)o(e)f(one)h(executable)f(program:)28b Fg(facetrain)o Fh(.)h(Brie\015y)l(,)19 b Fg(facetrain)dFh(tak)o(es)k(lists)f(of)h(image)0 513 y(\014les)c(as)h(input,)f(and)h(uses)g(these)f(as)h(training)f(and)i(test)e(sets)g(for)h(a)g(neural)f(net)o(w)o(ork.)22 b Fg(facetrain)13 b Fh(can)0 573 y(b)q(e)19b(used)f(for)h(training)f(and/or)i(recognition,)e(and)h(it)f(also)h(has)g(the)f(capabilit)o(y)f(to)i(sa)o(v)o(e)f(net)o(w)o(orks)g(to)0633 y(\014les.)62 735 y(The)d(co)q(de)f(has)h(b)q(een)f(compiled)e(and)j(tested)f(successfully)f(on)i(CS-side)f(Alphas,)g(DecStations,)h(Sun)0795 y(SP)l(AR)o(C-2s,)i(and)g(IBM)e(P)o(o)o(w)o(erPC's,)h(and)i(Andrew-side)e(DecStations)h(and)g(Sun)g(SP)l(AR)o(C-5s.)23b(If)16 b(y)o(ou)0 855 y(wish)g(to)h(use)f(the)f(co)q(de)i(on)f(some)f(other)h(platform,)f(feel)g(free,)g(but)h(b)q(e)g(a)o(w)o(are)g(that)g(the)g(co)q(de)g(has)h(only)0 915 y(b)q(een)f(tested)g(on)h(these)f(platforms.)62 1017 y(Details)j(of)g(the)f(routines,)h(explanations)g(of)g(the)g(source)g(\014les,)f(and)i(related)e(information)g(can)h(b)q(e)0 1077 y(found)e(in)f(Section)f Fi(??)23 b Fh(of)17b(this)f(handout.)0 1254 y Fi(2.)56 b(The)18 b(Assignmen)n(t)01405 y(2.1.)55 b(P)n(art)20 b(I)e(\(required\))0 1539y Fh(T)l(urn)d(in)g(a)g(short)h(write-up)f(of)g(y)o(our)g(answ)o(ers)g(to)h(the)e(questions)h(found)h(in)e(the)h(follo)o(wing)g(sequence)f(of)0 1599 y(initial)h(exp)q(erimen)o(ts.)60 1753 y(1.)24b(Issue)19 b(the)f(follo)o(wing)h(command)d(in)j(y)o(our)f(home)g(directory)g(to)h(obtain)g(the)g(training)g(and)g(test)1221813 y(set)d(data)h(for)g(this)f(assignmen)o(t:)122 1894y Fg(cp)25 b(/afs/cs/pr)o(oj)o(ect)o(/th)o(eo)o(-8/)o(fac)o(eim)o(ag)o(es/)o(tra)o(ins)o(et)o(/*.)o(lis)o(t)d(.)60 1995 y Fh(2.)i(The)15b(co)q(de)f(y)o(ou)h(ha)o(v)o(e)f(b)q(een)g(giv)o(en)g(is)g(curren)o(tly)f(set)i(up)f(to)h(learn)g(to)g(recognize)e(the)i(p)q(erson)g(with)122 2056 y(userid)h Fg(glickman)p Fh(.)k(Mo)q(dify)c(this)h(co)q(de)g(to)g(implem)o(en)n(t)d(a)j(\\sunglasses")i(recognizer;)c(i.e.,)g(train)122 2116 y(a)k(neural)f(net)g(whic)o(h,)g(when)g(giv)o(en)g(an)h(image)e(as)i(input,)f(indicates)g(whether)g(the)g(face)g(in)g(the)1222176 y(image)12 b(is)g(w)o(earing)h(sunglasses,)i(or)e(not.)21b(Refer)12 b(to)h(the)g(b)q(eginning)h(of)f(Section)f(3)i(for)f(an)h(o)o(v)o(erview)122 2236 y(of)i(ho)o(w)h(to)g(mak)o(e)d(c)o(hanges)j(to)f(this)g(co)q(de.)60 2337 y(3.)24 b(T)l(rain)17 b(a)h(net)o(w)o(ork)f(using)g(the)g(default)g(learning)g(parameter)f(settings)i(\(learning)f(rate)g(0.3,)h(mo-)122 2398 y(men)o(tum)13 b(0.3\))k(for)f(75)h(ep)q(o)q(c)o(hs,)f(with)h(the)f(follo)o(wing)f(command:)1222478 y Fg(facetrain)22 b(-n)j(shades.net)d(-t)j(straightrn)o(d)p1102 2478 16 2 v 15 w(train.list)d(-1)j(straightrnd)p1761 2478 V 15 w(test1.lis)o(t)122 2539 y(-2)g(straightrn)o(d)p487 2539 V 15 w(test2.list)d(-e)j(75)122 2619 y(facetrain)pFh(')o(s)12 b(argumen)o(ts)i(are)g(describ)q(ed)g(in)h(Section)fFi(??)p Fh(,)h(but)g(a)g(short)g(description)f(is)h(in)f(order)1222680 y(here.)20 b Fg(shades.net)12 b Fh(is)j(the)g(name)f(of)i(the)f(net)o(w)o(ork)g(\014le)f(whic)o(h)h(will)f(b)q(e)i(sa)o(v)o(ed)e(when)i(training)f(is)122 2740 y(\014nished.)k Fg(straightrnd)p606 2740 V 15 w(train.lis)o(t)p Fh(,)8 b Fg(straightrnd)p1188 2740 V 15 w(test1.list)o Fh(,)h(and)i Fg(straightrn)o(d)p1860 2740 V 15 w(test2.list)961 2844 y Fh(3)p eop%%Page: 4 44 3 bop 122 50 a Fh(are)15 b(text)f(\014les)h(whic)o(h)f(sp)q(ecify)h(the)f(training)h(set)g(\(70)h(examples\))d(and)j(t)o(w)o(o)f(test)g(sets)g(\(34)g(and)h(52)122 110 y(examples\),)e(resp)q(ectiv)o(ely)l(.)122 191 y(This)j(command)e(creates)i(and)g(trains)g(y)o(our)g(net)g(on)g(a)h(randomly)d(c)o(hosen)i(sample)f(of)h(70)h(of)f(the)122251 y(156)c(\\straigh)o(t")g(images,)e(and)h(tests)g(it)f(on)i(the)e(remaining)g(34)h(and)h(52)f(randomly)f(c)o(hosen)g(images,)122311 y(resp)q(ectiv)o(ely)l(.)29 b(One)20 b(w)o(a)o(y)f(to)h(think)g(of)g(this)f(test)h(strategy)g(is)g(that)g(roughly)1614 292y Fe(1)p 1614 300 18 2 v 1614 329 a(3)1656 311 y Fh(of)g(the)g(images)122 372 y(\()p Fg(straightrn)o(d)p 429 372 16 2 v 15w(test2.list)p Fh(\))d(ha)o(v)o(e)j(b)q(een)h(held)f(o)o(v)o(er)g(for)h(testing.)35 b(The)21 b(remaining)1807 352 y Fe(2)p 1807360 18 2 v 1807 389 a(3)1851 372 y Fh(ha)o(v)o(e)122432 y(b)q(een)14 b(used)g(for)g(a)h(train)f(and)h(cross-v)m(alidate)f(strategy)l(,)g(in)g(whic)o(h)1358 412 y Fe(2)p 1358420 V 1358 449 a(3)1395 432 y Fh(of)g(these)g(are)g(b)q(eing)g(used)h(for)122 492 y(as)k(a)f(training)g(set)g(\()p Fg(straightrn)o(d)p797 492 16 2 v 16 w(train.lis)o(t)p Fh(\))d(and)1205472 y Fe(1)p 1205 480 18 2 v 1205 509 a(3)1245 492 yFh(are)j(b)q(eing)h(used)f(for)g(the)g(v)m(alidation)122552 y(set)e(to)h(decide)e(when)h(to)h(halt)f(training)g(\()pFg(straightrnd)p 1185 552 16 2 v 15 w(test1.lis)o(t)pFh(\).)60 654 y(4.)24 b(What)17 b(co)q(de)f(did)g(y)o(ou)f(mo)q(dify?)21 b(What)16 b(w)o(as)h(the)f(maxim)n(um)c(classi\014cation)k(accuracy)g(ac)o(hiev)o(ed)122 714 y(on)h(the)g(training)g(set?)23b(Ho)o(w)17 b(man)o(y)e(ep)q(o)q(c)o(hs)i(did)g(it)f(tak)o(e)g(to)i(reac)o(h)e(this)h(lev)o(el?)k(Ho)o(w)16 b(ab)q(out)j(for)122774 y(the)g(v)m(alidation)g(set?)31 b(The)20 b(test)f(set?)31b(Note)19 b(that)g(if)g(y)o(ou)h(run)f(it)g(again)h(on)g(the)f(same)f(system)122 834 y(with)d(the)f(same)g(parameters)g(and)h(input,)g(y)o(ou)f(should)i(get)f(exactly)e(the)i(same)f(results)g(b)q(ecause,)122895 y(b)o(y)k(default,)g(the)h(co)q(de)f(uses)h(the)f(same)g(seed)g(to)h(the)f(random)h(n)o(um)o(b)q(er)d(generator)j(eac)o(h)f(time.)122955 y(Y)l(ou)23 b(will)e(need)h(to)h(read)g(Section)f(3.1.2)h(carefully)e(in)i(order)g(to)g(b)q(e)f(able)h(to)g(in)o(terpret)e(y)o(our)122 1015 y(exp)q(erimen)o(ts)14 b(and)i(answ)o(er)h(these)f(questions.)60 1117 y(5.)24 b(No)o(w,)19 b(implem)o(en)o(t)d(a)j(1{of{20)j(face)c(recognizer;)h(i.e.)29 b(implem)o(en)n(t)16b(a)k(neural)f(net)g(that)g(accepts)122 1177 y(an)h(image)f(as)h(input,)g(and)h(outputs)f(the)g(userid)g(of)g(the)f(p)q(erson.)33b(T)l(o)20 b(do)h(this,)f(y)o(ou)g(will)e(need)122 1237y(to)g(implem)o(en)n(t)d(a)i(di\013eren)o(t)g(output)h(enco)q(ding)g(\(since)e(y)o(ou)i(m)o(ust)e(no)o(w)i(b)q(e)f(able)g(to)h(distinguish)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -