Pomwe nyengo ya mbale yaku koleji yatsala pang’ono kuyandikira, okonda mpira m’dziko lonselo azisangalatsidwa, osati ndi zochitika zapabwalo, komanso ndi “makadi a makadi” opangidwa ndi anthu omwe ali mubwaloli. Kugwiritsiridwa ntchito kwa anthu ogwirizana kwambiri kumatha kupanga zithunzi zatsatanetsatane zomwe zimafanana ndi zithunzi za pixelated pakompyuta – ndipo zojambulidwa mofanana kwambiri.Buku latsopano los angeles Michael Littman, Code to Pleasure: Why Each Must Be informed a Little Programming ndi zitsanzo zofananira za momwe makina otizungulira amagwirira ntchito komanso momwe sitiyenera kudalira tsogolo lodzaza ndi automaton bola titaphunzira kulankhula chilankhulo chawo (osachepera mpaka atamaliza kuphunzira zathu). Kuchokera pakutsata malamulo mpaka kusunga zosinthika, Code to Pleasure imapereka chiwongolero chofikirika komanso chosangalatsa kuzinthu zoyambira zamapulogalamu zamakhodi ongoyamba kumene azaka zonse. MIT PressOchokera ku Code to Pleasure: Chifukwa Chake Aliyense Ayenera Kuphunzira Madongosolo Aang’ono a Michael L Littman. Lofalitsidwa ndi MIT Press. Copyright © 2023 ndi Michael L Littman. Ufulu wonse ndi wotetezedwa. “GANIZIRANI BLUE!” Makadi amphamvu, pamene omvera amanyamulira zikwangwani zamitundumitundu kuti apange zikwangwani zazikulu zosakhalitsa, ali ngati zipolopolo zomwe otenga nawo mbali safunikira luso lapadera ndipo alibe nkomwe. kuyeserera pasadakhale. Zomwe akuyenera kuchita ndikuwonetsa ndikutsatira malangizo munjira yachidule cha lamulo. Malangizowa amatsogolera omvera kuti anyamule makadi achikala owoneka bwino m’mwamba nthawi yoyenera monga momwe adalengezedwera ndi mtsogoleri wamasewera. Mndandanda wa malangizo a khadi-stunt amayamba ndi malangizo otsatila malangizo: mverani malangizo mosamala gwirani pamwamba pa khadi pamtunda wa diso (osati pamwamba pa mutu wanu) gwirani mtundu wosonyeza kumunda (osati kuyang’anana ndi inu) perekani makadi kupita munjira mukamaliza kudodometsa. (osang’amba makhadi)Malangizowa angamveke omveka, koma kusawatchula kumabweretsa tsoka. Ngakhale zili choncho, mukudziwa kuti payenera kukhala munthu wanzeru yemwe amafunsa pambuyo pake, “Pepani, woyamba uja analinso chiyani?” Ndizowona zomwe ndikanachita.Kenako pakubwera chochitika chachikulu, chomwe, kwa munthu mmodzi payekha pagulu los angeles anthu, chikhoza kukhala ndondomeko ya lamulo:BlueBlueBlueBreathtaking, ayi? Chabwino, mwina muyenera kuwona chithunzi chachikulu. Lingaliro lonse los angeles kudodometsa kwa makadi limatengera mfundo yakuti mamembala a gulu los angeles masewera amakhala pamipando yokonzedwa mu gridi. Ponyamula zikwangwani zamitundu yamakona anayi, amadzisintha kukhala chowonera chachikulu pakompyuta. Wotenga nawo mbali aliyense amakhala ngati chithunzi chimodzi – ma pixel amunthu! Kusintha komwe makhadi akukwezedwa kumasintha chithunzicho kapena mwina kuchipangitsa kuti chizisintha ngati gif.Zochita zamakadi zidayamba ngati kutenga nawo mbali pagulu pamasewera akukoleji m’ma Twenties. Anayamba kuchepa kwambiri m’zaka za m’ma 1970 pamene adagwirizana kuti aliyense azichita zofuna zake, amuna. Komabe, m’zaka za m’ma 1950, panali njala yeniyeni yopangira ziwonetsero zowonjezereka. Magulu a Cheer squads amatha kupanga zojambulazo pamanja, kenaka amakonzekeretsa aliyense pampando chikwi chimodzi. Muyenera kukonda gulu lanu kuti lipereke mphamvu zotere. Masukulu angapo m’zaka za m’ma 1960 adaganiza kuti zinthu zapakompyuta zatsopanozi zitha kukhala zothandiza pochotsa zovuta pakukonzekeretsa maphunziro ndipo adapanga mapulogalamu osinthira zithunzi zojambula pamanja kukhala malangizo apadera kwa aliyense wa ophunzira. Mothandizidwa ndi makompyuta, anthu amatha kupanga ma pixel olemera kwambiri a munthu aliyense payekhapayekha omwe amanena nthawi yokweza khadi, mtundu woti anyamule, ndi nthawi yoti aiike pansi kapena kusintha kukhala khadi ina. Kotero, pamene chitsanzo cha mafunso kuchokera m’gawo lapitalo chinali chokhudza anthu omwe amatsatira malamulo a makompyuta kuti atsatire, chitsanzo ichi ndi cha makompyuta kupanga masanjidwe a malamulo kuti anthu azitsatira. Ndipo kuthandizira pakompyuta pakudzipangitsa kuti pakhale njira zotsatirira malamulo kumapangitsa kuti pakhale zovuta zambiri. Izi zinapangitsa kuti otenga nawo mbali azitsatira malamulo owoneka ngati: mmwamba pa 001 white003 blue005 white006 red008 white013 blue015 white021 downup pa 022 white035 downup pa 036 white043 blue044 downup pa 045 white057 Chabwino, tomwe tikuwona ngati zitsulo zokondweretsa kuwerenga070 chomaliza – mu chitsanzo chenicheni ichi, ndi gawo los angeles makanema ojambula a Stanford “S.” Kuti apereke malamulowa mogwirizana, wolengeza m’bwalo lamasewera amatchula nambala yoyambira (“40-one!”) ndipo wophunzira aliyense angathe kudziwa kuchokera mu malangizo ake choti achite (“Ndikunyamulabe khadi loyera. Ndinakweza pa 36, koma ndikukonzekera kusinthana ndi khadi los angeles buluu pamene chiwerengero chifika 43 “). Monga ndinanenera, sizovuta kuti anthu akhale nawo pa khadi, koma ndi chitsanzo chabwino kwambiri. kupanga ndi kutsatira ndondomeko za malamulo pomwe kompyuta imatiuza zoyenera kuchita m’malo mozungulira. Ndipo, mophweka momwe zingakhalire, nthawi zina zinthu zimangolakwika. Pamsonkhano wa Democratic Nationwide Conference wa 2016, omutsatira a Hillary Clinton adakonza makhadi ambiri. Ngakhale kuti cholinga chake chinali kusonyeza mgwirizano wokonda dziko lako, opezekapo ena sanafune kutenga nawo mbali. Chotsatira chake chinali chisokonezo chosawerengeka chomwe, mokhumudwitsa, chimayenera kutchula “Kulimba Pamodzi.” Masiku ano, makompyuta amapangitsa kukhala chinthu chophweka kutembenuza chithunzi kukhala malangizo okhudza mitundu yomwe iyenera kugwirizira. M’malo mwake, chithunzi chilichonse chosungidwa pakompyuta chimakhala kale ndi malangizo osakaniza zofiira, buluu, ndi zobiriwira kuti ziwonetsedwe pa chithunzi chilichonse. Vuto limodzi lochititsa chidwi pomasulira chithunzi kukhala malangizo opunthira makhadi ndikuti zithunzi zodziwika bwino zimakhala ndi madontho mamiliyoni achikuda (ma megapixel), pomwe gawo lopumira pamakadi m’bwalo lamasewera limakhala ndi mipando chikwi. M’malo mopempha munthu aliyense kuti anyamule makadi ting’onoting’ono 1,000, n’kwanzeru kuwerengera avereji ya mitundu ya mbali ya chithunzicho. Ndiye, kuchokera kusonkhanitsa kwa mitundu yomwe ilipo (titi, zosankha zachikale makumi asanu ndi limodzi mphambu zinayi za Crayola), makompyuta amangosankha pafupi kwambiri ndi pafupifupi. Mutha kusakaniza zobiriwira ndi zachikasu ndikusankha kuti chotsatiracho chikuwoneka ngati krayoni yobiriwira yamasika, koma mumaphunzitsa bwanji makina kuti azichita zimenezo? Tiyeni tione funso limeneli mozama. Zikuthandizani kudziwa momwe makompyuta angatithandizire kuwalangiza bwino. Kuphatikiza apo, kudzakhala kulowa kwathu kudziko losangalatsa los angeles kuphunzira makina. Pali njira zambiri zopangira mitundu. Chosavuta ndikutengerapo mwayi kuti dontho lililonse lamtundu mufayilo lachithunzi limasungidwa ngati kuchuluka kwa zofiira, zobiriwira, ndi buluu momwemo. Mtundu uliwonse umaimiridwa ngati nambala yonse pakati pa 0 ndi 255, pomwe 255 idasankhidwa chifukwa ndi mtengo waukulu kwambiri womwe mungapange ndi manambala asanu ndi atatu, kapena ma bits. Kugwiritsa ntchito kuchuluka kwa red-blue-green kumagwira ntchito bwino chifukwa zolandilira zamitundu m’maso amunthu zimamasulira mitundu yeniyeni yapadziko lapansi kukhala choyimira chomwechi. Ndiko kuti, ngakhale kuti chibakuwa chimafanana ndi utali winawake wa kuwala kwa kuwala, maso athu amauona ngati mtundu winawake wa mitundu yobiriwira, yabuluu, ndi yofiira. Onetsani wina kusakaniza komweko, ndipo adzawona chibakuwa. Chifukwa chake, kuti tifotokoze mwachidule gulu lalikulu los angeles ma pixel, angoyerekeza kuchuluka kwa buluu mu ma pixel, kuchuluka kwa zofiira mu ma pixel, ndi kuchuluka kwa zobiriwira mu ma pixel. Zimenezo zimagwira ntchito. Tsopano, zikuwonekeratu, pazophatikiza zakuthupi, zamalingaliro, ndi zaumisiri, mumapeza zotsatira zabwinoko pokulitsa zikhalidwe musanayambe kuwerengetsa, ndikukulitsa mikhalidwe pambuyo pakukula. Koma zimenezi si zofunika pakali pano. Chofunikira ndichakuti pali njira yamakina yopangira madontho angapo achikuda kuti apeze kadontho kamodzi komwe mtundu wake umafotokozera gululo mwachidule. Mtundu wapakatiwo ukangopangidwa, kompyuta imafunikira njira yopezera mtundu wapafupi kwambiri ndi makhadi omwe tili nawo. kupezeka. Ndi zambiri za sienna yowotchedwa kapena red-orange? Njira yodziwika bwino (ngati yopanda ungwiro) yoyerekeza momwe mitundu iwiri yofananira ikugwiritsira ntchito mtengo wake wofiyira-buluu-wobiriwira ndi yomwe imadziwika kuti Euclidean distance formulation. Izi ndi zomwe zikuwoneka ngati kutsatizana kwa malamulo:tengani kusiyana pakati pa kuchuluka kwa zofiira mumitundu iwiriyi sikweya imatenga kusiyana pakati pa kuchuluka kwa buluu mumitundu iwiriyi sikwaya imatenga kusiyana pakati pa kuchuluka kwa zobiriwira mumitundu iwiriyo masikweya mwake. yonjezerani mabwalo atatuwo pamodzi, tengani masikweya mizu kuti muone kuti ndi khadi liti lomwe liyenera kusungidwa kuti lijambule pafupifupi mitundu yonse yamitundu yomwe ili mugawo lofananira los angeles chithunzicho, ingodziwani mitundu yomwe ilipo (buluu, chikasu, apricot, timberwolf). , mahogany, periwinkle, and so on.) ali ndi kamtunda kakang’ono kwambiri kumtundu wapakati pawo. Ndilo mtundu wa khadi lomwe liyenera kuperekedwa kwa munthu wa pixel atakhala pamalo amenewo mu gridi.Kufanana pakati pa kuwerengera mtunda uwu ndi ntchito yowonetsera mtundu, ndikutsimikiza, mwangozi. Nthawi zina sikweya mizu imangokhala masikweya mizu.Kubwerera m’mbuyo, titha kugwiritsa ntchito izi – kutengera mtundu ndikupeza mtundu wapafupi kwambiri ndi wapakati – kuti tipeze kompyuta yotithandiza kupanga katsatidwe kakuwongolera makadi. Kompyutayo imatenga chithunzi chomwe mukufuna, tchati chokhalamo, ndi makadi amitundu omwe alipo, kenako imapanga mapu a khadi lomwe liyenera kuimitsidwa pampando uliwonse kuti chithunzicho chiwoneke bwino. Muchitsanzo ichi, kompyuta nthawi zambiri imagwira ntchito zosungitsa mabuku ndipo ilibe zambiri popanga zisankho kupitilira kusankha mtundu wapafupi kwambiri. Koma chowonjezera apa ndikuti kompyuta ikutenga zina mwazolemba zamalamulo. Tachoka pakusankha lamulo lililonse los angeles pixel ya munthu aliyense mphindi iliyonse pakusintha kwamakhadi mpaka kusankha zithunzi ndikupangitsa kuti kompyuta ipange malamulo oyenera. ndondomeko yopangira makina ku makina. Pankhani ya gridi yathu ya 2 × 2 kuchokera pamutu 1, titha kuchoka pakunena (kupereka malangizo omveka bwino) kupita kukufotokozera (kupereka zolimbikitsa zomveka). Mwachitsanzo, pali kusiyana kwa vuto losankha mtundu uwu lomwe ndi lovuta kwambiri ndipo limapatsa kompyuta ntchito yosangalatsa yochita. Tiyerekeze kuti titha kusindikiza makhadi amtundu uliwonse umene timafuna koma shopu yathu yosindikizira ikuumirira kuti tiziitanitsa makadiwo mochulukira. Amatha kutipatsa mitundu isanu ndi itatu ya makadi, koma titha kusankha mitundu yomwe tikufuna kupanga eyitiyo. (Eyiti ndi chiwerengero cha zinthu zosiyanasiyana zomwe tingapange ndi 3 bits – bits zimabwera kwambiri mu computing.) Kotero tikhoza kusankha buluu, buluu, buluu, blue-violet, cerulean, indigo, cadet blue, ndi sky blue. , ndikupereka mafunde okongola a m’nyanja yamitundu isanu ndi itatu ya buluu. Zabwino! Koma ndiye sipakanakhala zofiira kapena zachikasu kupanga zithunzi zina. Kuchepetsa phale lamitundu mpaka eyiti kumatha kumveka ngati chovuta, koma zikuwoneka kuti oyang’anira makompyuta oyambirira adagwira ntchito chimodzimodzi. Amatha kuwonetsa mtundu uliwonse mwamitundu mamiliyoni, koma mitundu isanu ndi itatu yokha pa skrini nthawi ina iliyonse. Sikuti mumangofunika kusankha mtundu wamtundu wamitundu yomwe mungasankhe kuti mupange khadi lililonse, monga kale, koma muyenera kusankha mitundu isanu ndi itatu yomwe ipange mitunduyo. Ngati tikupanga nkhope, mitundu yosiyanasiyana ya khungu idzakhala yothandiza kwambiri kuposa kusiyanitsa pakati pa mithunzi yobiriwira kapena yabuluu. Kodi timachoka bwanji pamndandanda wamitundu yomwe tikufuna kuti tigwiritse ntchito chifukwa ili pachithunzi chandamale kupita ku mndandanda wawufupi kwambiri wamitundu yomwe ingapange zosankha zathu zamitundu? Kuphunzira pamakina, makamaka njira yotchedwa clustering kapena kuphunzira mosayang’aniridwa, kungathe kuthetsa vuto losankha mitundu imeneyi kwa ife. Ndikuuzani bwanji. Koma choyamba tiyeni tifufuze vuto lina lomwe limabwera chifukwa chosandutsa nkhope kukhala jigsaw puzzle. Monga mu chitsanzo cha khadi-stunt, tidzakhala ndi makompyuta apangidwe katsatidwe ka malamulo operekera chithunzi. Koma pali zopindika – zidutswa zazithunzi zomwe zilipo popanga chithunzizo zimakhazikika pasadakhale. Mofanana ndi chitsanzo cha kuvina, idzagwiritsa ntchito malamulo omwewo ndikuganiziranso ndondomeko yomwe imapanga chithunzi chomwe mukufuna.