% cd ..
/Users/do-hyungkwon/GoogleDrive
% cd .
/Users/do-hyungkwon/GoogleDrive
!ls ./script_programming/
README.md Speech The Python Challenge.webloc Untitled.ipynb Untitled1.ipynb Untitled2.ipynb Untitled3.ipynb aaa assignment-1.ipynb assignment-2.ipynb assignment-3.ipynb assignment-4.ipynb assignment-5.ipynb example files images module_test.py music mymath.py mymath.pyc pickle.txt pickle2.txt python01.ipynb python02.ipynb python03.ipynb python04.ipynb python05.ipynb python06.ipynb python07.ipynb python08.ipynb python09.ipynb python10.ipynb python11.ipynb python12.ipynb python13.ipynb python14.ipynb python15.ipynb python16.ipynb python17.ipynb python18.ipynb python19.ipynb python20.ipynb python21.ipynb python22.ipynb python23.ipynb python3.6 readme.txt removeme.txt sample.txt sample_new.txt supplement-2016-09.ipynb supplement.ipynb t.txt t1.txt t2.txt turtle_example.png turtle_method-1.png turtle_method-2.png turtle_method-3.png 범이의 데이터 아키텍처 -- [Python] [개념을 잡아주는 프로그래밍 정석] 4.8 연습문제.webloc
%ls ./script_programming/
README.md Speech/ The Python Challenge.webloc Untitled.ipynb Untitled1.ipynb Untitled2.ipynb Untitled3.ipynb aaa/ assignment-1.ipynb assignment-2.ipynb assignment-3.ipynb assignment-4.ipynb assignment-5.ipynb example/ files/ images/ module_test.py music mymath.py mymath.pyc pickle.txt pickle2.txt python01.ipynb python02.ipynb python03.ipynb python04.ipynb python05.ipynb python06.ipynb python07.ipynb python08.ipynb python09.ipynb python10.ipynb python11.ipynb python12.ipynb python13.ipynb python14.ipynb python15.ipynb python16.ipynb python17.ipynb python18.ipynb python19.ipynb python20.ipynb python21.ipynb python22.ipynb python23.ipynb python3.6/ readme.txt removeme.txt sample.txt* sample_new.txt supplement-2016-09.ipynb supplement.ipynb t.txt t1.txt t2.txt turtle_example.png turtle_method-1.png turtle_method-2.png turtle_method-3.png 범이의 데이터 아키텍처 -- [Python] [개념을 잡아주는 프로그래밍 정석] 4.8 연습문제.webloc
list?
1 + 1
2
_+ 10
12
def square(x):
return x+x
def cube(x):
return x*x*x
funcs = {
'square' : square,
'cube' : cube,
}
x = 2
print(square(x))
print(cube(x))
for func in sorted(funcs):
print(func, funcs[func](x))
4 8 cube 8 square 4
sorted(funcs)
['cube', 'square']
%cd TEST
[Errno 2] No such file or directory: 'TEST' /Users/do-hyungkwon/GoogleDrive
%cd /Users/do-hyungkwon/GoogleDrive/jupyter_notebook/
/Users/do-hyungkwon/GoogleDrive/jupyter_notebook
!ls
CNN 랩세미나.ipynb Data_preprocessing_작업_1.ipynb Data_preprocessing_작업_2.ipynb MNIST_data MNIST_load_관련.ipynb MODEL_작업.ipynb One Hidden Layer with Backpropagation.ipynb RP_data RP_data_2 RP_data_3 RP_data_4 Two Hidden Layers with Backward Propagation.ipynb Two_hidden_layers_tf_all_in_one (1).ipynb Two_hidden_layers_tf_all_in_one.ipynb cvt_img.jpg data_preprocessing.ipynb data_preprocessing_only_code.ipynb dataset dataset 복사본 dataset.zip dataset2_gray dataset_jpg dataset_jpg_gray dataset_old github_reference image.jpg image.png image2.jpg image2.png image_dataset_origin image_grayscale.jpg image_grayscale.png image_jpg.jpg image_resolution.ipynb image_resolution.jpg image_resolution.png image_resolution_gray.jpg imdata jpg_image.jpg mnist.pkl out.txt output resized_image.jpg t10k-images-idx3-ubyte.gz t10k-images.idx3-ubyte t10k-images.idx3-ubyte.textClipping t10k-labels-idx1-ubyte.gz test-input-image-large.jpg test_img_dataset.txt test_label.txt train-images-idx3-ubyte.gz train-labels-idx1-ubyte.gz train_image_1 train_img_dataset (1).txt train_img_dataset.txt train_label.txt transpose 시키기.ipynb validation_img_dataset.txt validation_label.txt 무제 폴더 압축된 파일 압축된 파일 2 압축된 파일 2.zip 압축된 파일.zip
%%writefile test.txt
Hello World!
Writing test.txt
with open('test.txt', 'r') as f:
print(f.read())
Hello World!
!ㅣㄴ
/bin/sh: ㅣㄴ: command not found
!cd ../deeplink\ 복사본\(170830\)
!pwd
/Users/do-hyungkwon/GoogleDrive/jupyter_notebook
%cd /Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4
/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4
!pwd
/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4
!ls
deep_convnet.py deeplink train_deepnet.py deep_convnet_large.py realtime_deepnet.py
%run deep_convnet.py
%cd /Users/do-hyungkwon/GoogleDrive/script_programming/
/Users/do-hyungkwon/GoogleDrive/script_programming
!pwd
/Users/do-hyungkwon/GoogleDrive/script_programming
!ls
README.md Speech The Python Challenge.webloc Untitled.ipynb Untitled1.ipynb Untitled2.ipynb Untitled3.ipynb aaa assignment-1.ipynb assignment-2.ipynb assignment-3.ipynb assignment-4.ipynb assignment-5.ipynb example files images module_test.py music mymath.py mymath.pyc pickle.txt pickle2.txt python01.ipynb python02.ipynb python03.ipynb python04.ipynb python05.ipynb python06.ipynb python07.ipynb python08.ipynb python09.ipynb python10.ipynb python11.ipynb python12.ipynb python13.ipynb python14.ipynb python15.ipynb python16.ipynb python17.ipynb python18.ipynb python19.ipynb python20.ipynb python21.ipynb python22.ipynb python23.ipynb python3.6 readme.txt removeme.txt sample.txt sample_new.txt supplement-2016-09.ipynb supplement.ipynb t.txt t1.txt t2.txt turtle_example.png turtle_method-1.png turtle_method-2.png turtle_method-3.png 범이의 데이터 아키텍처 -- [Python] [개념을 잡아주는 프로그래밍 정석] 4.8 연습문제.webloc
%cd files/
/Users/do-hyungkwon/GoogleDrive/script_programming/files
pwd
'/Users/do-hyungkwon/GoogleDrive/script_programming/files'
ls
cal.py
run cal.py
November 2014 Mo Tu We Th Fr Sa Su 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
from random import random
list1 = [random() for _ in range(1000)]
list2 = [random() for _ in range(1000)]
list1
[0.8906521355143266, 0.9411147714820817, 0.7804547949560583, 0.5565488890114239, 0.1675965834732981, 0.9961753695390924, 0.7040020712147955, 0.38253504778387004, 0.45368358290881217, 0.25355061337382956, 0.2672552956575043, 0.6050477289701843, 0.8424952461572698, 0.1275147906498707, 0.22303978598373808, 0.1664971540760215, 0.06652914529610676, 0.6180379127849815, 0.3213185909028219, 0.10689945381224497, 0.5527757923246033, 0.8847197619262366, 0.7380255999216774, 0.40797049410154407, 0.7867984802091843, 0.09392793581948133, 0.5026767895051878, 0.6894596355865844, 0.47518875491953405, 0.2563860798769977, 0.09829298802605824, 0.2800054957246366, 0.5245561917828271, 0.4625956844604717, 0.9647353223605971, 0.25363847206753853, 0.27062943398980455, 0.4292767631485831, 0.6016309951807896, 0.2425311475949059, 0.2708718452427975, 0.8410942742994247, 0.7076626731131904, 0.4349780553735505, 0.6101468678238938, 0.9628358660351191, 0.50787232639313, 0.19929031404822917, 0.7776392651746117, 0.596315990946178, 0.41861357287419976, 0.6651679412959837, 0.750474763624549, 0.9661368657913829, 0.5089024406666991, 0.7354463748478013, 0.09497766464880975, 0.09424419367453896, 0.12293681423501968, 0.42652202528137717, 0.1881995522190052, 0.2675351797857326, 0.22909427302775687, 0.06450427542447912, 0.7255620675202342, 0.9440762510639312, 0.20935421173816637, 0.6987366468203453, 0.17017138130986453, 0.98845107146034, 0.8272270722358799, 0.32363794649361877, 0.7052698077142502, 0.7535129090580979, 0.017389818909191557, 0.9545472488264697, 0.15593007077152843, 0.09876849294472356, 0.9760493048344576, 0.464679148953284, 0.4939750505488254, 0.7448501914587642, 0.9419530972597471, 0.08299087004401484, 0.9082253042564365, 0.9101201246636987, 0.6487826725954161, 0.7719910654388294, 0.1657343392142715, 0.6846319090729774, 0.135941626121867, 0.9548203928842505, 0.24354716174037971, 0.7014651713645369, 0.377756299672678, 0.4039251252025665, 0.8805644754793612, 0.9848070038230552, 0.101364009524058, 0.814610689414146, 0.2764296774105439, 0.7582161311010016, 0.8433085374230027, 0.9791718729058797, 0.28193121542622523, 0.4444235117391039, 0.7261370802549258, 0.47104717339382496, 0.30321429759015206, 0.15194046643645098, 0.151750842099991, 0.03328295214749888, 0.5470309619084058, 0.5704311126067306, 0.014696562472400698, 0.8626990442880106, 0.14704106695397745, 0.1502025366515839, 0.2346334161996304, 0.7180969750156572, 0.7113043390575634, 0.21323803834200483, 0.2420734045982218, 0.5325439949178782, 0.4401685498282234, 0.7574494063824962, 0.4891949660620566, 0.7813829739525571, 0.09302073769691499, 0.5008371025932495, 0.5802509062451713, 0.06499969853948073, 0.653011578089733, 0.5760757445482727, 0.4503446082074335, 0.5350597767788111, 0.0685894312031502, 0.6114678905354857, 0.05229565997711183, 0.9920424573606702, 0.6527249448974296, 0.24686836096277764, 0.05974522984882902, 0.058920299103052964, 0.7385559651948027, 0.626832702645902, 0.08999661397581227, 0.1537240027410779, 0.49437937456545167, 0.6123646190813579, 0.67914765023922, 0.9721137596715812, 0.2811524341943532, 0.19595749217983016, 0.3731070514293616, 0.5645393029678304, 0.11421690135794227, 0.4523933947313755, 0.3644150802082047, 0.5869138752629045, 0.9979969758573962, 0.7257180090213093, 0.6222226974395423, 0.23493988506782226, 0.5859297177865612, 0.4685636087087166, 0.553991410954111, 0.5298048309143187, 0.898303326912493, 0.5766332413326658, 0.5829612989484693, 0.7930452282304372, 0.0014406609008057458, 0.7174950331937783, 0.2248256742085708, 0.41211601725966573, 0.9042503758303949, 0.5675410127998509, 0.7073289024172765, 0.10187498245451698, 0.3983328402679971, 0.9219942305467737, 0.8062580871824581, 0.7730404782160887, 0.09335502094929438, 0.09665616623599338, 0.2674026880200606, 0.22025540561138868, 0.833988996372183, 0.7607437183326718, 0.16013465439217445, 0.9919815084321758, 0.5135932560489845, 0.45154732223369065, 0.03679631885997914, 0.4617277816117905, 0.2902626233695871, 0.7740033896845459, 0.6060730687145843, 0.47945706732002846, 0.8066507902037541, 0.7885727615589638, 0.7090895814881933, 0.08494926140500514, 0.9734161306683388, 0.8530510645228727, 0.11023292095453563, 0.906099614589677, 0.6851502539436924, 0.5302782896844955, 0.36960343826870623, 0.1712597659688343, 0.30801742004149113, 0.670214238077765, 0.745412124699968, 0.6147276857679034, 0.36827188515159837, 0.6257808886820829, 0.5179538382295488, 0.2745125605300518, 0.2294287968455273, 0.6452699442872718, 0.942885783476578, 0.1336854133749652, 0.7318135980673219, 0.548303313763799, 0.047342343946420895, 0.9647007390667192, 0.08968109139666058, 0.6461792481567697, 0.7637170228083586, 0.2745802587065431, 0.19867868545650957, 0.554855405988693, 0.7771812843379996, 0.8812611346620008, 0.4381753037620848, 0.8248679493363693, 0.9762907045587493, 0.631333843715891, 0.27728320738580914, 0.27629744564800696, 0.23997146380537926, 0.21157811371327462, 0.18947164981373033, 0.23825920994904248, 0.43282186244843135, 0.29235496943275563, 0.33073375735230204, 0.09847024163465912, 0.6731028034763012, 0.8240274523226628, 0.7648508624546608, 0.7263644918010195, 0.3662872278599123, 0.7396970112693434, 0.6179539230584127, 0.12192609204209959, 0.40030789626300034, 0.5484269834234121, 0.11978807951014148, 0.7303035284841418, 0.7732293407589955, 0.6201156909731009, 0.8856387721204052, 0.30627236077339526, 0.9965020830278548, 0.32492561378848217, 0.11475594841845393, 0.7680313165865831, 0.12617776921642732, 0.607336239437735, 0.5482648563019241, 0.6157060818808558, 0.6788141786205582, 0.816328129016195, 0.369751613413584, 0.6384806372201333, 0.19103550881117093, 0.5579655618034486, 0.3022109576867196, 0.3570067208505183, 0.23188845866578378, 0.36216499331899665, 0.438439827629603, 0.7509973610502606, 0.6445800683335232, 0.5549423932934785, 0.8424219895560678, 0.546495053329773, 0.17669322896229023, 0.23616002435559869, 0.03720015630803475, 0.31474451397236314, 0.39745421229080946, 0.28278009602903975, 0.24523137891090618, 0.7079073840942186, 0.2237571565510046, 0.07370587288101371, 0.6255332275846475, 0.7093160557286216, 0.9826110971591816, 0.187871889015229, 0.715078145180598, 0.9040501508688799, 0.7119890451289799, 0.04829529933834342, 0.9037625570956181, 0.9287995634178282, 0.5517783369748923, 0.7825007625072714, 0.1412658617882041, 0.5950643456616183, 0.9903742884075254, 0.7152248837337644, 0.550377835556066, 0.3985419809055136, 0.6827999988128265, 0.09547327220278579, 0.16735902585005458, 0.17860752214929798, 0.6020777014286678, 0.766751265370302, 0.7390091601844704, 0.1490909511538061, 0.7898790759634261, 0.868828995121904, 0.19086039762451013, 0.7511228771309847, 0.33096416159579234, 0.033745210998792796, 0.2539615262597672, 0.5210736435105959, 0.6338303204011876, 0.837761227452584, 0.8654311259461396, 0.2945551502271849, 0.49732460008930224, 0.649152384597229, 0.5873056299654781, 0.4352887202474788, 0.6020397658468944, 0.026848436672716636, 0.4860033551891041, 0.5155574485797518, 0.241314848550217, 0.8810994415655596, 0.6710515455198917, 0.8824955083051832, 0.6907379417152949, 0.29095871104631477, 0.3126618565858359, 0.10688912543340456, 0.7535018944079602, 0.5445590158698508, 0.5082531044531775, 0.36148733459953153, 0.323518420533221, 0.6844246952040048, 0.3586933893054465, 0.9883524970316806, 0.8007100551522597, 0.4601261254511747, 0.21417409842008894, 0.2754481571062041, 0.5578269550600579, 0.012415124154566692, 0.557511426059515, 0.6860607078233003, 0.37780010701767397, 0.9217481577860227, 0.5198250523268422, 0.28313960837503616, 0.10386031758302028, 0.7516053018580537, 0.6139267393107208, 0.2933273186822877, 0.3924277820567895, 0.06056076920197673, 0.5136222587527923, 0.9117666488736245, 0.7729539089639393, 0.26778531944812667, 0.808577719636022, 0.7854120106543958, 0.14807001129480857, 0.36987050547188094, 0.11365568132163917, 0.9941346784478152, 0.8694181462894334, 0.33624671101162074, 0.38279091197092585, 0.337091135320578, 0.599228759380874, 0.5168904504845704, 0.5514760558669733, 0.2123057841298459, 0.563924688160489, 0.14935238968108144, 0.36422415512965445, 0.33948943969520784, 0.15094294246754736, 0.5083344764183755, 0.9817004154231833, 0.1936829343948352, 0.937181222111137, 0.20774959421963024, 0.15217388839229007, 0.8666237495538743, 0.3085830141903706, 0.6788818833374827, 0.3964771160250171, 0.7170790918296804, 0.8404633724483365, 0.7711190951328972, 0.06081211785931784, 0.6699733869554183, 0.1567239731527379, 0.19816655373124048, 0.39498339974389385, 0.5490434322922609, 0.758215153214554, 0.24639673354225144, 0.2513637296476976, 0.9072807918487498, 0.909864307483793, 0.8219713071858732, 0.06343305096955842, 0.2413750895862966, 0.8373697896318855, 0.10088725276769905, 0.8234652768694825, 0.9898451098464872, 0.2741774196488348, 0.3204575061892846, 0.913812299751609, 0.01627777524042051, 0.019214197110193232, 0.8918554785161156, 0.5605429389711616, 0.3510981396649355, 0.30647677106073035, 0.24165196784933696, 0.7528358182682695, 0.6430440975237283, 0.996554082404646, 0.31199887832706086, 0.5226073350365015, 0.013117183869266857, 0.929073724567767, 0.9056644184831865, 0.27666798168008355, 0.013424340183557426, 0.40268143731200456, 0.6636386755018382, 0.7082887812174197, 0.38388198171527366, 0.6097272859781498, 0.7528756593444385, 0.8798375027273956, 0.6068872218156756, 0.3503471833088141, 0.8259047800943611, 0.8128957298697691, 0.8939785672476354, 0.5422478460844449, 0.31553270280095336, 0.6405279583068977, 0.3597656214633017, 0.2889108849322164, 0.4922047268067693, 0.8327915693104457, 0.3277076019379853, 0.8713873896344992, 0.22875060118724422, 0.9335890629035303, 0.255549412689544, 0.15066464164432813, 0.26887126359558167, 0.6870525877771586, 0.40321644990700256, 0.21013692040443488, 0.927714246450664, 0.155627162724428, 0.22089571137545683, 0.1856468152454388, 0.6362632878989183, 0.3905133553223773, 0.855933713950714, 0.8920788605276186, 0.6570342194697744, 0.03552951249395264, 0.0854598557437426, 0.45040756859605224, 0.35518855369442004, 0.40637374298242257, 0.04125872025522703, 0.23945713126801393, 0.5670871197377014, 0.572252538193618, 0.9398853635693121, 0.5010616410267318, 0.06310206526146356, 0.7456365270336127, 0.41012989070992123, 0.4612365298643435, 0.480783962817934, 0.01823284932245839, 0.6045690257242677, 0.7323229929954058, 0.2552058013791828, 0.8326417394732437, 0.1455396944829176, 0.13525678385215545, 0.7656868316315776, 0.8432022082764987, 0.781981694278368, 0.025076340553529697, 0.3083068698280029, 0.2813683537144741, 0.3678254114903755, 0.8902277149873913, 0.49945943353884426, 0.7436971589099858, 0.6479599381095483, 0.3712311720244241, 0.38729730643836546, 0.8429567139162144, 0.3160290435240478, 0.8439813135528312, 0.022657537834802732, 0.8279050102713803, 0.589057387008456, 0.1744405132320862, 0.9304713071233417, 0.1118724148784489, 0.5585915409633939, 0.36710263708886315, 0.7880875938422518, 0.4500890590921822, 0.15588745163815365, 0.6832525065297202, 0.351333399664318, 0.4422251953532498, 0.6020749530160101, 0.05800902406630637, 0.8871833708923571, 0.17293030154193412, 0.8881813676377167, 0.8152385921900354, 0.8883621118137052, 0.24994248091443794, 0.6346087407504215, 0.007409547331956534, 0.6466245985290132, 0.9906712590709404, 0.9258152596555992, 0.8235714594188183, 0.00820886418289346, 0.1564023795766205, 0.7075112325030009, 0.45046812414263393, 0.5911727835292879, 0.13165687832297945, 0.6463898107731514, 0.3791229887152431, 0.7429290997603721, 0.5393949815897895, 0.06756654684174623, 0.8348262297484119, 0.20121327568999114, 0.7413328877074865, 0.7551177230762839, 0.7146575874270747, 0.8844823659212648, 0.23735993955420076, 0.6914975259351099, 0.8764515360375389, 0.696770830780297, 0.04869723304377638, 0.9248141004688473, 0.6346465788457116, 0.9203249646855708, 0.20858040486274865, 0.8998031941486211, 0.6389461557039012, 0.2543104018287141, 0.3980304507905016, 0.6250016608324598, 0.5181827683448409, 0.7979136584953345, 0.4394905469196051, 0.889946556616781, 0.19608331260691392, 0.06995220836770522, 0.22558059472520997, 0.2726678737169881, 0.9631775414614565, 0.5053163702433562, 0.8681496115491595, 0.7010289838956199, 0.32551351669642015, 0.20020898122743158, 0.21304052815710284, 0.8672297406123692, 0.06706518432321562, 0.3366187574402736, 0.015403806346035442, 0.5571312934528229, 0.0030607510856648368, 0.8973373586546259, 0.8366158396437623, 0.9300799597474323, 0.8274993649109533, 0.6636425272589911, 0.4032192694695742, 0.8014704051714401, 0.7893422846588837, 0.01949472326966839, 0.5928310456872478, 0.9595547442169445, 0.48982769392964953, 0.02302644522493158, 0.8979821128495366, 0.4047791280579025, 0.9417645793679189, 0.03182106568715404, 0.7451316958965996, 0.03908742839824575, 0.40363289606490227, 0.42686687022303793, 0.7256468545258421, 0.07901011772303812, 0.6170220347520461, 0.34395477650193074, 0.14732145454843237, 0.5634419861994799, 0.6224180510879168, 0.9694057023937046, 0.5996378010117973, 0.34558974935055664, 0.8795236890285335, 0.5690266553779714, 0.07677763951180039, 0.8668386787059219, 0.7216617368735014, 0.5427092026568575, 0.8102873287805434, 0.889426909455728, 0.57252329747637, 0.6067287203796544, 0.8193191118332643, 0.4287647106842756, 0.241662505833954, 0.17252287442490788, 0.9701174965872575, 0.06454611808261512, 0.9824078033973592, 0.31611321096389455, 0.38628779936293434, 0.21981750292631708, 0.40324354013994135, 0.6386471169936873, 0.4232656481934438, 0.6253548675076551, 0.16982522474203232, 0.660428490721169, 0.25781412469382703, 0.6718146435850441, 0.47914643361134557, 0.7852909645980428, 0.6999900566643491, 0.3416879021410333, 0.9811152308479636, 0.13592103432969904, 0.6674596571765482, 0.9275143842122004, 0.8863380471417094, 0.4727317386162361, 0.5788479074038737, 0.15673909538451292, 0.05808074647979822, 0.7336513960885409, 0.7749770965767294, 0.1414115671545274, 0.319604737521191, 0.5036514328469441, 0.5862087311368712, 0.5008767376663589, 0.8265947013947362, 0.37152996367594227, 0.6466387449500726, 0.6323371148386964, 0.4969668067027486, 0.7239243102677253, 0.2593655809119946, 0.9310347562005588, 0.17235066013736888, 0.5298394746573245, 0.4663354089127364, 0.12113663573881617, 0.8927613281738414, 0.09868332626032783, 0.8764057468885407, 0.8490790680224228, 0.5067936186721479, 0.61859494298449, 0.6875298105574691, 0.23650658837303062, 0.5398938258759405, 0.05839282690829983, 0.531676159684144, 0.08603705659626637, 0.2508254680230062, 0.9580702923221974, 0.4956185307487825, 0.41582221073333114, 0.5007721935451569, 0.07564554948054236, 0.4943233278226117, 0.7750302138256457, 0.20846841965662566, 0.6527705642976147, 0.6995448652052507, 0.6547533197388147, 0.4489962331294467, 0.8633843607945841, 0.07919849981498239, 0.26796167380446634, 0.6738509152013517, 0.1569654894485074, 0.31820993029205613, 0.6928884673833002, 0.7587971602392171, 0.7490173342722976, 0.4824491825877838, 0.6281411806192793, 0.09110325736333902, 0.2272515609773178, 0.8300714081995345, 0.41178988713639, 0.4189639151605795, 0.4683789638902187, 0.6972926175720812, 0.5558608586604736, 0.17006793466420045, 0.4736318741474931, 0.6739944623635545, 0.3852029662425318, 0.06596301813141048, 0.711352749234049, 0.1722965267377452, 0.9243873307922549, 0.7512188761222433, 0.17826138260944635, 0.5356118428720802, 0.472975693943153, 0.2191212200134237, 0.7471472493258948, 0.8630583562465127, 0.7930120103154057, 0.5891615468984037, 0.4385573627192042, 0.16083267047758454, 0.0993715635130431, 0.6143735482802161, 0.153321608460109, 0.10958459590034897, 0.2556698781646224, 0.7946031323787635, 0.43494179805872324, 0.4384593737995929, 0.15630140641576862, 0.06003968650938507, 0.3521621709247097, 0.8433002173635781, 0.3512415544815639, 0.017669556585916846, 0.33852272994203925, 0.31511778436869287, 0.09896568801626626, 0.13925919896559402, 0.21611392419445308, 0.6954010147128646, 0.2743535128911705, 0.45166316617071267, 0.8241967539458284, 0.45174706467345316, 0.22387199077143327, 0.733063380255207, 0.13190596789725695, 0.14394744981479335, 0.8789896714473392, 0.3098511346808893, 0.2485071835148288, 0.4152447097283827, 0.7219990770694189, 0.3216155163173309, 0.5215505490215091, 0.07523128039357874, 0.6219693122475783, 0.27784126178160984, 0.8140562627536082, 0.2917008151080812, 0.4093929709390103, 0.5648879882730428, 0.7361542728017286, 0.8212090786218893, 0.07013528872709607, 0.31676367673132344, 0.01079559565897581, 0.8586201511211767, 0.8804093764835589, 0.3823853538891071, 0.2730895041466681, 0.10761734347058638, 0.6599789388411261, 0.5482427700075484, 0.481931570546979, 0.19475385554315372, 0.6448258090530742, 0.4254620173386673, 0.7554116431903065, 0.127028955248344, 0.2494022885867686, 0.7801736074499507, 0.7507550177431044, 0.9122774025383312, 0.7476190302247077, 0.62735789450706, 0.29369417032751766, 0.0634458282295165, 0.8937470613392255, 0.12776978731932043, 0.393060683324883, 0.04389682009429341, 0.5735226948919407, 0.22043870967014678, 0.5280297014552133, 0.5617479102547562, 0.578401149119267, 0.2286083039974951, 0.26375232167437024, 0.8999510292903707, 0.9607032487036469, 0.09006187012109423, 0.5726284845446513, 0.7858940875001008, 0.4540544969410881, 0.8609854460231324, 0.4094331644267043, 0.9841874603642817, 0.2776519210797088, 0.7407439459693145, 0.13000032201141865, 0.02380745061531042, 0.4156141586500848, 0.4710992207743143, 0.6003590494643708, 0.880802731575251, 0.7272104838481421, 0.023661617369377885, 0.034847472110794975, 0.4516109161866728, 0.2123226280745899, 0.0010867342230801436, 0.842320221552167, 0.2138517696453145, 0.7614995678783137, 0.9778573087964333, 0.061879074922035704, 0.8076652624997437, 0.011999586117784622, 0.12585876095553628, 0.4441735305777964, 0.4300509567286114, 0.3556466089340079, 0.5936610141953973, 0.7142437913222099, 0.8684047267235078, 0.7252166875299394, 0.8816060879704407, 0.7012037187893029, 0.03667481151190477, 0.23999996113462452, 0.2560156902763383, 0.716205308276198, 0.9622029957783733, 0.3936059595626942, 0.0810520100546831, 0.03742264086081337, 0.21819340355672823, 0.716199716040054, 0.48720463898073074, 0.4891441701279411, 0.4020778090582948, 0.8428007505497782, 0.2630960822097007, 0.007650714029847627, 0.25159136548244687, 0.49199466838377315, 0.1295895642495326, 0.38102985464507233, 0.3651215701855689, 0.49093465381441526, 0.8596025034265571, 0.27440584930369993, 0.1365371114498165, 0.9037554994194104, 0.03311243679510012, 0.9295779359271258, 0.695181384736449, 0.9920405506961665, 0.11346140124162629, 0.605215827841329, 0.04201963160029132, 0.5374148346137307, 0.9669263488973885, 0.8022969643597431, 0.20393944576277012, 0.7771265702760175, 0.2730208545372995, 0.0022832654599138635, 0.36480353625747364, 0.1400662854393504, 0.9011733699693759, 0.4889989135626587, 0.6659470409250522, 0.08281452357789043, 0.9102585686969998, 0.6364724235562397, 0.40741171412099775, 0.6040479018601236, 0.342513984629501, 0.5165676315652069, 0.7683533106987636, 0.8717383964028812, 0.34260904790103797, 0.06750039778151273, 0.9205594908341374, 0.4566072441813641, 0.1799828518598694, 0.1804251041936208, 0.566798529458963, 0.9889093667295235, 0.8220910104175041, 0.8139790740673143, 0.15969432013150953, 0.6262572783105068, 0.5469744159884337, 0.7269687186823531, 0.34722768884308286, 0.9416929596554047, 0.08924967764979752, 0.6261876038136575, 0.7995080845514368, 0.08058831639145825, 0.1808784795058065, 0.2310996616372345, 0.6357501240474868, 0.8559826583558066, 0.279747090459033, 0.16283790504318896, 0.9888156289774844, 0.3047527083951137, 0.8260228996116487, 0.09187778648829614, 0.7399331996820916, 0.19735448077436757, 0.44863966806698174, 0.24724391775446164, 0.9493809492862807, 0.6407616904479276, 0.6141627065590668, 0.3347774197069435, 0.6433229889446616, 0.07099211520076609, 0.1704726695092751, 0.4472737096421391, 0.6865717838346901, 0.23513463630025844, 0.18145865993017674, 0.09134103190575293, 0.3231558991782195, 0.8446415920601732, 0.4321187683248696, 0.40087210145386787, 0.7834198704566174, 0.29055149263098945, 0.6518876180976012, 0.6099160154393811, 0.9870452328370816, 0.008320756235908888, 0.2773119610829933, 0.870675552187072, 0.961880190034377, 0.9568629317594524, 0.04779194428477007, 0.12545196673393544]
import numpy as np
arr1 = np.array(list1)
arr2 = np.array(list2)
arr1.shape
(1000,)
arr1.dtype
dtype('float64')
arr1.strides
(8,)
arr1.ndim
1
from IPython.display import Image
pwd
'/Users/do-hyungkwon/GoogleDrive/script_programming/files'
cd /Users/do-hyungkwon/Downloads/
/Users/do-hyungkwon/Downloads
ls
2017011014840263686501382.jpg
2017011014840269617281400.jpg
2017011014840273545251412.jpg
2017012014849019897551623.jpg
2017012014849025086141638.jpg
2017012314851700225172162.jpg
2017012314851719908292210.jpg
2017년도 이공분야 대학중점연구소지원사업 연구개발과제계획서(신청용).pdf
< 2016 첨단기술연구소 정기 학술 워크샵 개최 >.jpg
< 연구소 발행 학술지 표지 >3.jpg
< 산학협력관 202호 세미나실 >1.jpg
< 산학협력관 202호 세미나실 >2..jpg
School_Bus_Picture4.hwp
java-json.jar.zip
★ ATRC Image Works IV.pdf
무제 폴더/
붙임3_안전교육신청 방법.pdf
붙임4_연구활동종사자 교육ㆍ훈련의 시간 및 내용(제9조제1항 관련).hwp
Image(filename="2017011014840273545251412.jpg")
type(Image)
type
Image
IPython.core.display.Image
img = np.asarray(Image)
type(img)
numpy.ndarray
img[0]
--------------------------------------------------------------------------- IndexError Traceback (most recent call last) <ipython-input-74-02e97476df11> in <module>() ----> 1 img[0] IndexError: too many indices for array
from IPython.display import YouTubeVideo
YouTubeVideo("y1f-YHw1uNs")
YouTubeVideo("y1f-YHw1uNs")
files = !ls -l | grep .
files
['total 23088', '-rw-r--r--@ 1 do-hyungkwon staff 105121 8 31 21:08 2017011014840263686501382.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 313258 8 31 21:09 2017011014840269617281400.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 251477 8 31 21:09 2017011014840273545251412.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 135565 8 31 21:10 2017012014849019897551623.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 235959 8 31 21:10 2017012014849025086141638.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 128405 8 31 21:11 2017012314851700225172162.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 209520 8 31 21:12 2017012314851719908292210.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 2599836 8 19 15:47 2017년도 이공분야 대학중점연구소지원사업 연구개발과제계획서(신청용).pdf', '-rw-r--r--@ 1 do-hyungkwon staff 1116459 8 31 12:32 < 2016 첨단기술연구소 정기 학술 워크샵 개최 >.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 438798 8 31 12:33 < 연구소 발행 학술지 표지 >3.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 220185 8 31 12:33 < 산학협력관 202호 세미나실 >1.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 203689 8 31 12:33 < 산학협력관 202호 세미나실 >2..jpg', '-rw-r--r--@ 1 do-hyungkwon staff 2450432 8 31 11:47 School_Bus_Picture4.hwp', '-rw-r--r--@ 1 do-hyungkwon staff 81955 8 31 16:19 java-json.jar.zip', '-rw-r--r--@ 1 do-hyungkwon staff 2823105 8 19 15:47 ★ ATRC Image Works IV.pdf', 'drwxr-xr-x 5 do-hyungkwon staff 170 8 31 21:16 무제 폴더', '-rw-r--r--@ 1 do-hyungkwon staff 447686 8 31 11:33 붙임3_안전교육신청 방법.pdf', '-rw-r--r--@ 1 do-hyungkwon staff 16896 8 31 11:33 붙임4_연구활동종사자 교육ㆍ훈련의 시간 및 내용(제9조제1항 관련).hwp']
files = !ls -l -S | grep .
files
['total 23088', '-rw-r--r--@ 1 do-hyungkwon staff 2823105 8 19 15:47 ★ ATRC Image Works IV.pdf', '-rw-r--r--@ 1 do-hyungkwon staff 2599836 8 19 15:47 2017년도 이공분야 대학중점연구소지원사업 연구개발과제계획서(신청용).pdf', '-rw-r--r--@ 1 do-hyungkwon staff 2450432 8 31 11:47 School_Bus_Picture4.hwp', '-rw-r--r--@ 1 do-hyungkwon staff 1116459 8 31 12:32 < 2016 첨단기술연구소 정기 학술 워크샵 개최 >.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 447686 8 31 11:33 붙임3_안전교육신청 방법.pdf', '-rw-r--r--@ 1 do-hyungkwon staff 438798 8 31 12:33 < 연구소 발행 학술지 표지 >3.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 313258 8 31 21:09 2017011014840269617281400.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 251477 8 31 21:09 2017011014840273545251412.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 235959 8 31 21:10 2017012014849025086141638.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 220185 8 31 12:33 < 산학협력관 202호 세미나실 >1.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 209520 8 31 21:12 2017012314851719908292210.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 203689 8 31 12:33 < 산학협력관 202호 세미나실 >2..jpg', '-rw-r--r--@ 1 do-hyungkwon staff 135565 8 31 21:10 2017012014849019897551623.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 128405 8 31 21:11 2017012314851700225172162.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 105121 8 31 21:08 2017011014840263686501382.jpg', '-rw-r--r--@ 1 do-hyungkwon staff 81955 8 31 16:19 java-json.jar.zip', '-rw-r--r--@ 1 do-hyungkwon staff 16896 8 31 11:33 붙임4_연구활동종사자 교육ㆍ훈련의 시간 및 내용(제9조제1항 관련).hwp', 'drwxr-xr-x 5 do-hyungkwon staff 170 8 31 21:16 무제 폴더']
lsmagic
Available line magics: %alias %alias_magic %autocall %automagic %autosave %bookmark %cat %cd %clear %colors %config %connect_info %cp %debug %dhist %dirs %doctest_mode %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %lf %lk %ll %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %lx %macro %magic %man %matplotlib %mkdir %more %mv %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %popd %pprint %precision %profile %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %rep %rerun %reset %reset_selective %rm %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode Available cell magics: %%! %%HTML %%SVG %%bash %%capture %%debug %%file %%html %%javascript %%js %%latex %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile Automagic is ON, % prefix IS NOT needed for line magics.
history
% cd .. % . % .. % cd . !ls *.ipynb !ls *.ipynb %ls *.ipynb !ls !ls ./deeplink/5.DoHyung/ !ls ./ !ls ./script_programming/ %ls ./script_programming/ list? 1 + 1 _+ 10 def square(x): return x+x def cube(x): return x*x*x funcs = { 'square' : square, 'cube' : cube, } x = 2 print(square(x)) print(cube(x)) for func in sorted(funcs): print(func, funcs[func](x)) sorted(funcs) x = 2 print(square(x)) print(cube(x)) for func, val in sorted(funcs): print(func) print(val) # print(func, funcs[func](x)) x = 2 print(square(x)) print(cube(x)) for func, val in sorted(funcs): print(func, funcs[func](x)) x = 2 print(square(x)) print(cube(x)) for func, val in sorted(funcs): print(func, funcs[func](x)) x = 2 print(square(x)) print(cube(x)) for funcin sorted(funcs): print(func, funcs[func](x)) x = 2 print(square(x)) print(cube(x)) for func in sorted(funcs): print(func, funcs[func](x)) %cd TEST %cd /Users/do-hyungkwon/GoogleDrive/jupyter_notebook/ !ls %%writefile test.txt %%writefile test.txt Hello World! with open('test.txt', 'r') as f: print(f.read()) !ㅣㄴ !ls !ls *.py !pwd !cd ../deeplink\ 복사본\(170830\) !pwd ! cd ../deeplink/5.DoHyung/raspberrypi4/ !pwd !cd /Users/do-hyungkwon/GoogleDrive/deeplink\ 복사본\(170830\)/5.DoHyung/raspberrypi5/ !pwd !pwd !cd /Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4 !pwd %cd /Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4 !pwd !ls %run deep_convnet.py %cd /Users/do-hyungkwon/GoogleDrive/script_programming/ !pwd !ls %cd files/ pwd ls run cal.py from random import random list1 = [random() for _ in range(1000)] list2 = [random() for _ in range(1000)] list1 import numpy as np arr1 = np.array(list1) arr2 = np.array(list2) arr1.shape arr1.dtype arr1.strides arr1.ndim from IPython.display import Image pwd cd /Users/do-hyungkwon/Downloads/ ls Image(filename=2017011014840273545251412.jpg) Image(filename="2017011014840273545251412.jpg") type(Image) Image img = np.asarray(Image) type(img) img.shape img img[0] from IPython.display import YouTubeVideo YouTubeVideo("lmoNmY-cmSI") YouTubeVideo("y1f-YHw1uNs") YouTubeVideo("y1f-YHw1uNs") YouTubeVideo("y1f-YHw1uNs") YouTubeVideo("y1f-YHw1uNs") YouTubeVideo("y1f-YHw1uNs") files = !ls -l -S | grep . files files files = !ls -l | grep . files files = !ls -l -S | grep . files lsmagic history
%%capture
UsageError: %%capture is a cell magic, but the cell body is empty.
%whos
Variable Type Data/Info --------------------------------------------------------------------- AdaGrad type <class 'deeplink.optimizers.AdaGrad'> Adam type <class 'deeplink.optimizers.Adam'> Affine type <class 'deeplink.layers.Affine'> BatchNormalization type <class 'deeplink.layers.BatchNormalization'> Convolution type <class 'deeplink.layers.Convolution'> DeepConvNet type <class '__main__.DeepConvNet'> Dropout type <class 'deeplink.layers.Dropout'> Image type <class 'IPython.core.display.Image'> Momentum type <class 'deeplink.optimizers.Momentum'> Nesterov type <class 'deeplink.optimizers.Nesterov'> Pooling type <class 'deeplink.layers.Pooling'> RMSprop type <class 'deeplink.optimizers.RMSprop'> ReLU type <class 'deeplink.layers.ReLU'> SGD type <class 'deeplink.optimizers.SGD'> Sigmoid type <class 'deeplink.layers.Sigmoid'> SoftmaxWithCrossEntropyLoss type <class 'deeplink.layers.S<...>maxWithCrossEntropyLoss'> YouTubeVideo type <class 'IPython.lib.display.YouTubeVideo'> arr1 ndarray 1000: 1000 elems, type `float64`, 8000 bytes arr2 ndarray 1000: 1000 elems, type `float64`, 8000 bytes calendar module <module 'calendar' from '<...>b/python3.6/calendar.py'> col2im function <function col2im at 0x111c84048> cross_entropy_error function <function cross_entropy_error at 0x111bceae8> cube function <function cube at 0x1112f3950> f TextIOWrapper <_io.TextIOWrapper name='<...>ode='r' encoding='UTF-8'> files SList ['total 23088', '-rw-r--r<...> 8 31 21:16 무제 폴더'] func str square funcs dict n=2 identity_function function <function identity_function at 0x111bce620> im2col function <function im2col at 0x111bcef28> img ndarray : 1 elems, type `object`, 8 bytes list1 list n=1000 list2 list n=1000 mean_squared_error function <function mean_squared_error at 0x111bcea60> np module <module 'numpy' from '/Us<...>kages/numpy/__init__.py'> optimizers dict n=6 os module <module 'os' from '/Users<...>nda/lib/python3.6/os.py'> pickle module <module 'pickle' from '/U<...>lib/python3.6/pickle.py'> random builtin_function_or_method <built-in method random o<...>object at 0x7fadcf042618> relu function <function relu at 0x111bce8c8> relu_grad function <function relu_grad at 0x111bce950> sigmoid function <function sigmoid at 0x111bce7b8> sigmoid_grad function <function sigmoid_grad at 0x111bce840> softmax function <function softmax at 0x111bce9d8> softmax_loss function <function softmax_loss at 0x111bceb70> square function <function square at 0x1112f3a60> step_function function <function step_function at 0x111bce730> sys module <module 'sys' (built-in)> x int 2
%timeit
%pdb
%magic ?
ㅔㅈㅇ
--------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-2-d8574cd7073a> in <module>() ----> 1 ㅔㅈㅇ NameError: name 'ᅦᄌᄋ' is not defined
pwd
'/Users/do-hyungkwon/GoogleDrive/script_programming'
cd /Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4/
/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4
pwd
'/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4'
ls -l
total 64 -rwxr-xr-x 1 do-hyungkwon staff 9605 8 31 10:24 deep_convnet.py* -rwxr-xr-x 1 do-hyungkwon staff 11667 8 31 10:24 deep_convnet_large.py* drwxr-xr-x 12 do-hyungkwon staff 408 9 1 10:36 deeplink/ -rwxr-xr-x 1 do-hyungkwon staff 430 8 31 10:24 realtime_deepnet.py* -rwxr-xr-x 1 do-hyungkwon staff 3830 8 31 10:24 train_deepnet.py*
# %load deep_convnet.py
import sys, os
import pickle
import numpy as np
from deeplink.layers import *
from deeplink.optimizers import *
optimizers = {
"SGD": SGD,
"Momentum": Momentum,
"Nesterov": Nesterov,
"AdaGrad": AdaGrad,
"RMSprop": RMSprop,
"Adam": Adam
}
class DeepConvNet:
"""
conv - relu - poll - conv- relu - pool -
affine - relu - dropout - affine - dropout - softmax
"""
def __init__(self, input_dim=(1, 320, 240),
conv_param_1 = {'filter_num':16, 'filter_size':3, 'pad':1, 'stride':1},
pool_param_1 = {'size': 2, 'stride': 2},
conv_param_2 = {'filter_num':16, 'filter_size':3, 'pad':1, 'stride':1},
pool_param_2 = {'size': 2, 'stride': 2},
hidden_size=128, output_size=3, optimizer='AdaGrad', learning_rate=0.01, train_flg=False):
channel_num = input_dim[0]
layer_input_width = input_dim[1]
layer_input_height = input_dim[2]
self.last_conv_pool_input_width, self.last_conv_pool_input_height = self.get_conv_pool_last_output_size(input_dim[1], input_dim[2], conv_param_1, pool_param_1, conv_param_2, pool_param_2, train_flg)
pre_node_nums = np.array([
channel_num * conv_param_1['filter_size'] * conv_param_1['filter_size'],
conv_param_1['filter_num'] * conv_param_2['filter_size'] * conv_param_2['filter_size'],
conv_param_2['filter_num'] * self.last_conv_pool_input_width * self.last_conv_pool_input_height,
hidden_size])
weight_init_scales = np.sqrt(2.0 / pre_node_nums)
self.params = {}
for idx, conv_param in enumerate([conv_param_1, conv_param_2]):
self.params['W' + str(idx+1)] = weight_init_scales[idx] * np.random.randn(conv_param['filter_num'], channel_num, conv_param['filter_size'], conv_param['filter_size'])
self.params['b' + str(idx+1)] = np.zeros(conv_param['filter_num'])
channel_num = conv_param['filter_num']
self.params['W3'] = weight_init_scales[2] * np.random.randn(16 * self.last_conv_pool_input_width * self.last_conv_pool_input_height, hidden_size)
self.params['b3'] = np.zeros(hidden_size)
self.params['W4'] = weight_init_scales[3] * np.random.randn(hidden_size, output_size)
self.params['b4'] = np.zeros(output_size)
self.layers = []
self.layers.append(Convolution(self.params['W1'], self.params['b1'],
conv_param_1['stride'], conv_param_1['pad']))
self.layers.append(ReLU())
self.layers.append(Pooling(pool_h=pool_param_1['size'], pool_w=pool_param_1['size'], stride=pool_param_1['stride']))
self.layers.append(Convolution(self.params['W2'], self.params['b2'],
conv_param_2['stride'], conv_param_2['pad']))
self.layers.append(ReLU())
self.layers.append(Pooling(pool_h=pool_param_2['size'], pool_w=pool_param_2['size'], stride=pool_param_2['stride']))
self.layers.append(Affine(self.params['W3'], self.params['b3']))
self.layers.append(ReLU())
self.layers.append(Dropout(0.5))
self.layers.append(Affine(self.params['W4'], self.params['b4']))
self.layers.append(Dropout(0.5))
self.last_layer = SoftmaxWithCrossEntropyLoss()
# Optimizer Initialization
self.optimizer = optimizers[optimizer](lr=learning_rate)
def get_conv_pool_last_output_size(self, layer_input_width, layer_input_height, conv_param_1, pool_param_1, conv_param_2, pool_param_2, train_flg):
layer_input_width, layer_input_height = self.conv_layer_output_size(layer_input_width,
layer_input_height,
conv_param_1['filter_size'],
conv_param_1['pad'], conv_param_1['stride'])
if train_flg: print("Shape of Conv-1 Output: ({:d}, {:d}, {:d})".format(conv_param_1['filter_num'], layer_input_width, layer_input_height))
layer_input_width, layer_input_height = self.pool_layer_output_size(layer_input_width,
layer_input_height,
pool_param_1['size'],
pool_param_1['size'],
pool_param_1['stride'])
if train_flg: print("Shape of Pool-1 Output: ({:d}, {:d}, {:d})".format(conv_param_1['filter_num'], layer_input_width, layer_input_height))
layer_input_width, layer_input_height = self.conv_layer_output_size(layer_input_width,
layer_input_height,
conv_param_2['filter_size'],
conv_param_2['pad'], conv_param_2['stride'])
if train_flg: print("Shape of Conv-2 Output: ({:d}, {:d}, {:d})".format(conv_param_2['filter_num'], layer_input_width, layer_input_height))
layer_input_width, layer_input_height = self.pool_layer_output_size(layer_input_width,
layer_input_height,
pool_param_2['size'],
pool_param_2['size'],
pool_param_2['stride'])
if train_flg: print("Shape of Pool-2 Output: ({:d}, {:d}, {:d})".format(conv_param_2['filter_num'], layer_input_width, layer_input_height))
return int(layer_input_width), int(layer_input_height)
def conv_layer_output_size(self, layer_input_width, layer_input_height, filter_size, pad, stride):
size_w, size_h = (layer_input_width - filter_size + 2 * pad) / stride + 1, (layer_input_height - filter_size + 2 * pad) / stride + 1
if size_w != int(size_w):
raise ValueError("Conv_Layer output size (size_w) is not integer")
if size_h != int(size_h):
raise ValueError("Conv_Layer output size (size_h) is not integer")
return int(size_w), int(size_h)
def pool_layer_output_size(self, layer_input_width, layer_input_height, filter_width, filter_height, stride):
size_w, size_h = (layer_input_width - filter_width) / stride + 1, (layer_input_height - filter_height) / stride + 1
if size_w != int(size_w):
raise ValueError("Pool_Layer output size (size_w) is not integer")
if size_h != int(size_h):
raise ValueError("Pool_Layer output size (size_h) is not integer")
return int(size_w), int(size_h)
def predict(self, x, train_flg=False):
isFirstAffine = False
for layer in self.layers:
if isinstance(layer, Affine) and not isFirstAffine:
isFirstAffine = True
x = x.reshape(-1, 16 * self.last_conv_pool_input_width * self.last_conv_pool_input_height)
if isinstance(layer, Dropout):
x = layer.forward(x, train_flg)
else:
x = layer.forward(x)
return x
def loss(self, x, t):
y = self.predict(x, train_flg=True)
return self.last_layer.forward(y, t)
def accuracy(self, x, t, batch_size=10):
if t.ndim != 1 : t = np.argmax(t, axis=1)
acc = 0.0
for i in range(int(x.shape[0] / batch_size)):
tx = x[i*batch_size:(i+1)*batch_size]
tt = t[i*batch_size:(i+1)*batch_size]
y = self.predict(tx, train_flg=False)
y = np.argmax(y, axis=1)
acc += np.sum(y == tt)
return acc / x.shape[0]
def backpropagation_gradient(self, x, t):
# forward
self.loss(x, t)
# backward
dout = 1
dout = self.last_layer.backward(dout)
tmp_layers = self.layers.copy()
tmp_layers.reverse()
isFirstPooling = False
for layer in tmp_layers:
if isinstance(layer, Pooling) and not isFirstPooling:
isFirstPooling = True
dout = dout.reshape(-1, 16, self.last_conv_pool_input_width, self.last_conv_pool_input_height)
dout = layer.backward(dout)
# 設定
grads = {}
for i, layer_idx in enumerate((0, 3, 6, 9)):
grads['W' + str(i+1)] = self.layers[layer_idx].dW
grads['b' + str(i+1)] = self.layers[layer_idx].db
return grads
def learning(self, x_batch, t_batch):
grads = self.backpropagation_gradient(x_batch, t_batch)
self.optimizer.update(self.params, grads)
def save_params(self, file_name="params.pkl"):
with open(file_name, 'wb') as f:
pickle.dump(self.params, f)
def load_params(self, file_name="params.pkl"):
with open(file_name, 'rb') as f:
params = pickle.load(f)
for key, val in params.items():
self.params[key] = val
for i, layer_idx in enumerate((0, 3, 6, 9)):
self.layers[layer_idx].W = self.params['W' + str(i+1)]
self.layers[layer_idx].b = self.params['b' + str(i+1)]
import numpy as np
x = np.random.random(500)
%timeit np.sum(x*x)
The slowest run took 312.49 times longer than the fastest. This could mean that an intermediate result is being cached. 100000 loops, best of 3: 4.5 µs per loop
history -l 5
x = np.random.random(500) import numpy as np x = np.random.random(500) %timeit np.sum(x) %timeit np.sum(x*x)
dhist
Directory history (kept in _dh) 0: /Users/do-hyungkwon/GoogleDrive/script_programming 1: /Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4
contents = !ls
print(contents[:2])
['deep_convnet.py', 'deep_convnet_large.py']
print(contents)
['deep_convnet.py', 'deep_convnet_large.py', 'deeplink', 'realtime_deepnet.py', 'train_deepnet.py']
print(type(contents))
<class 'IPython.utils.text.SList'>
path = !cd
print(path)
[]
pwd
'/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4'
message = "hello from Python"
!echo {message}
hello from Python
!env
TERM_PROGRAM=Apple_Terminal VIRTUALENVWRAPPER_PROJECT_FILENAME=.project VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh rvm_bin_path=/Users/do-hyungkwon/.rvm/bin GEM_HOME=/Users/do-hyungkwon/.rvm/gems/ruby-2.2.0 SHELL=/bin/bash TERM=xterm-color CLICOLOR=1 TMPDIR=/var/folders/v5/h58bg81s0jx2y4hqbgk_dgw40000gn/T/ IRBRC=/Users/do-hyungkwon/.rvm/rubies/ruby-2.2.0/.irbrc Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.mBPj2NVg19/Render TERM_PROGRAM_VERSION=388.1.1 TERM_SESSION_ID=7B5A326D-51E5-452E-A071-495CE7E7FF42 MY_RUBY_HOME=/Users/do-hyungkwon/.rvm/rubies/ruby-2.2.0 USER=do-hyungkwon _system_type=Darwin rvm_path=/Users/do-hyungkwon/.rvm SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.JHJriDNVjz/Listeners __CF_USER_TEXT_ENCODING=0x1F5:0x3:0x33 JPY_PARENT_PID=96449 PAGER=cat WORKON_HOME=/Users/do-hyungkwon/.virtualenvs rvm_prefix=/Users/do-hyungkwon PATH=/Users/do-hyungkwon/anaconda/bin:/Users/do-hyungkwon/.rvm/gems/ruby-2.2.0/bin:/Users/do-hyungkwon/.rvm/gems/ruby-2.2.0@global/bin:/Users/do-hyungkwon/.rvm/rubies/ruby-2.2.0/bin:/Users/do-hyungkwon/anaconda/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/do-hyungkwon/.rvm/bin _=/usr/bin/env VIRTUALENVWRAPPER_HOOK_DIR=/Users/do-hyungkwon/.virtualenvs PWD=/Users/do-hyungkwon/GoogleDrive/deeplink/5.DoHyung/raspberrypi4 MPLBACKEND=module://ipykernel.pylab.backend_inline LANG=ko_KR.UTF-8 XPC_FLAGS=0x0 _system_arch=x86_64 _system_version=10.12 XPC_SERVICE_NAME=0 rvm_version=1.29.2 (latest) SHLVL=2 HOME=/Users/do-hyungkwon LOGNAME=do-hyungkwon GEM_PATH=/Users/do-hyungkwon/.rvm/gems/ruby-2.2.0:/Users/do-hyungkwon/.rvm/gems/ruby-2.2.0@global VIRTUALENVWRAPPER_WORKON_CD=1 GIT_PAGER=cat SECURITYSESSIONID=186a7 RUBY_VERSION=ruby-2.2.0 _system_name=OSX
!wget https://raw.githubusercontent.com/ipython-books/minbook-2nd-data/master/nyc_taxi.zip
--2017-09-01 11:24:20-- https://raw.githubusercontent.com/ipython-books/minbook-2nd-data/master/nyc_taxi.zip Resolving raw.githubusercontent.com... 151.101.72.133 Connecting to raw.githubusercontent.com|151.101.72.133|:443... connected. HTTP request sent, awaiting response... 404 Not Found 2017-09-01 11:24:20 ERROR 404: Not Found.
!sudo apt-get install wget
Password:
a = int(1)
print(a)
print(type(a))
print(isinstance(a, int))
1 <class 'int'> True
lt = [1, 's', ['b', 'c']]
print(id(lt), type(lt))
4437881032 <class 'list'>
print(id(lt[0]), type(lt[0]))
4395628544 <class 'int'>
print(id(lt[1]), type(lt[1]))
4398017312 <class 'str'>
import array
L = list(range(10))
A = array.array('i', L)
print(A)
array('i', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
print(type(A))
<class 'array.array'>
print(A.typecode)
i
print(A.tolist())
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
type(A.tolist())
list