-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCODE.html
More file actions
1170 lines (623 loc) · 51.5 KB
/
CODE.html
File metadata and controls
1170 lines (623 loc) · 51.5 KB
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<!-- Basic Page Needs
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CODE</title>
<meta name="description" content="">
<!-- Mobile Specific Metas
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/github-io/assets/main.css">
<!-- FONT
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link href='http://fonts.googleapis.com/css?family=Raleway:400,600,700,800' rel='stylesheet' type='text/css'>
<link href="https://fonts.googleapis.com/css?family=Libre+Baskerville:400,700,400italic" rel="stylesheet" type="text/css">
<!-- CSS
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="stylesheet" href="./css/styles.css">
<!-- Favicon
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
<link rel="shortcut icon" href="./favicon.ico"/>
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Top Bar -->
<section class="top-bar">
<div class="container">
<div class="row">
<div class="box box-1">
<div class="socials">
<!--ul>
<li><a href="#!"><i class="icon-gplus-circled"></i></a></li>
<li><a href="#!"><i class="icon-facebook-circled"></i></a></li>
<li><a href="#!"><i class="icon-twitter-circled"></i></a></li>
<li><a href="#!"><i class="icon-vimeo-circled"></i></a></li>
</ul-->
</div>
</div>
<div class="box box-2">
<form class="search-box">
<div class="btn-close"></div>
<p>
<input class="search_bar" type="text" value="" placeholder="Search" data-active-placeholder="Type to search...">
</p>
<p class="help">
Press <strong>return</strong> to search. Press <strong>Esc</strong> to cancel.
</p>
</form>
</div>
</div>
</div>
</section>
<!-- Header -->
<header class="header article">
<div class="container">
<div class="logo">
<a href="index.html">
<h1>CODING</h1>
<h6>CODING Blog</h6>
</a>
</div>
</div>
</header>
<!-- Main Nav -->
<section class="container">
<nav class="nav" style="">
<ul style="position:relative;">
<li><a href="/github-io/C.html">C/C++</a></li>
<li><a href="/github-io/R.html">R</a></li>
<li><a href="/github-io/Python.html">Python</a></li>
<li><a href="/github-io/Java.html">Java</a></li>
<li><a href="/github-io/Swift.html">Swift</a></li>
</ul>
</nav>
</section>
<section class="main container">
<div class="catalogue">
<a href="/github-io/2020-09-02/C-02_Opt" class="catalogue-item">
<div>
<time datetime="2020-09-02 00:00:00 +0800" class="catalogue-time">September 02, 2020</time>
<h1 class="catalogue-title">2019-2020 领悟的优化 基于c++</h1>
<div class="catalogue-line"></div>
<p>
背景 这两年来,主要精力集中在使用c++做矩阵计算上,由此总结了一些c++的优化手段,虽然可能几年以后会对现在的水平嗤之以鼻,但至少可以记录一下自己的编程水平增长经历,以下希望随时间持续更新。 所谓代码的优化,个人认为有三个方面:更快,更省,更好看。快指的是时间少,省指的是省空间,好看指代码简洁。这三者有时候会有冲突,而我所追求的则是达到三者的平衡,有时甚至可以兼顾三者,个人的水平毕竟是有限的。对于尚未工作的我来说,更深层次的优化其实掌握得并不多,目前使用的优化,或许也仅限于单机以及平日研究所用。 底层优化 底层优化是我掌握得比较浅薄的方法。其核心在于利用计算机的金字塔物理结构,提高运算效率。CPU运算速度非常快,但数据在外存,也就是磁盘上,而计算通常都是发生在CPU,一个程序,分为计算密集型和io密集型,我通常面对的任务都是计算密集型,所以重点在于充分利用CPU。这里可以存在的优化有: 读写文件优化 通常网上教读写文件的方式是利用fstream,将文件转化为数据流,之后再按照数据类型,一个个地读入和转化数据,这里的优化就可以利用内存和缓存,先将所有的数据读入到内存,之后再进行数据的转换。两种代码如下: int n; ifstream...
</p>
</div>
</a>
<a href="/github-io/2020-06-28/C-Python-05_read_graph" class="catalogue-item">
<div>
<time datetime="2020-06-28 00:00:00 +0800" class="catalogue-time">June 28, 2020</time>
<h1 class="catalogue-title">读取Graph数据的代码</h1>
<div class="catalogue-line"></div>
<p>
背景 记录读图的一些代码,由于图一般都会储存为稀疏矩阵的形式,否则大图根本无法储存,所以最终返回的都是稀疏矩阵,比较节约空间的是csr matrix。 CSR Matrix and COO Matrix COO Matrix...
</p>
</div>
</a>
<a href="/github-io/2020-04-04/C-03_Eigen_speed" class="catalogue-item">
<div>
<time datetime="2020-04-04 00:00:00 +0800" class="catalogue-time">April 04, 2020</time>
<h1 class="catalogue-title">如何提高Eigen效率</h1>
<div class="catalogue-line"></div>
<p>
背景 为了加速c++的矩阵计算,MKL是比较好的方案,但MKL写代码实在不太友好,其次容易出bug。MKL计算矩阵乘法速度十分快,但其实对代码优化到极致之后,Eigen矩阵计算速度是可以和MKL媲美的。由此,我也对CMake进行了一定的研究。我主要是从知乎Eigen的速度为什么这么快?中学习到的。我仅作为搬运工,并加入一些自己的实际探索。 优化手段 从知乎中总结: 矩阵乘法,若等式左边的变量与右式相乘变量没有关系,则可以使用 A.noalias() 替代 A -mavx 和...
</p>
</div>
</a>
<a href="/github-io/2020-03-11/C-02_MKL_Begin" class="catalogue-item">
<div>
<time datetime="2020-03-11 00:00:00 +0800" class="catalogue-time">March 11, 2020</time>
<h1 class="catalogue-title">MKL 的坑与教训</h1>
<div class="catalogue-line"></div>
<p>
背景 为了加速c++,不可避免的需要使用矩阵运算库。最出名的、一般人用的最多的c++矩阵计算库可能是Eigen,从统计处我知道了Armadillo用的也不少。但说到底,python那些包用的最多的也许最后还是MKL。 MKL全称 Intel Math Kernel Library, 是由Intel 公司开发的,专门用于矩阵计算的库。这个库经过我自己的评测,性能远超 Eigen...
</p>
</div>
</a>
<a href="/github-io/2020-02-29/Python-03_Kmeans_with_Cython" class="catalogue-item">
<div>
<time datetime="2020-02-29 00:00:00 +0800" class="catalogue-time">February 29, 2020</time>
<h1 class="catalogue-title">Kmeans base on Cython</h1>
<div class="catalogue-line"></div>
<p>
背景 Kmeans 是机器学习比较基础的算法,利用包调用比较容易,未来的算法可以很复杂,但基础都是一样简单的。算法层面尽量写得简单,将优化过程尽量写复杂。由于想使用Cython,先写C++部分,这里需要定义命名空间。头文件代码如下: 代码 KMeans.h #ifndef KMEANS #define KMEANS #include...
</p>
</div>
</a>
<a href="/github-io/2019-04-23/CAL-03_Alias" class="catalogue-item">
<div>
<time datetime="2019-04-23 00:00:00 +0800" class="catalogue-time">April 23, 2019</time>
<h1 class="catalogue-title">Alias算法</h1>
<div class="catalogue-line"></div>
<p>
问题描述 O(1)时间内产生离散随机数的方法。 class Alias{ public: double* p; int* h; int*...
</p>
</div>
</a>
<a href="/github-io/2018-07-17/CAL-02_Sort" class="catalogue-item">
<div>
<time datetime="2018-07-17 00:00:00 +0800" class="catalogue-time">July 17, 2018</time>
<h1 class="catalogue-title">各式排序算法及其c语言实现</h1>
<div class="catalogue-line"></div>
<p>
问题描述 排序算法可以说是算法的一个基础,这里在我水平范围内进行总结和归纳,并给出我自己实现的源码。 以下,归纳基于比较的排序方法,因此,其运行时间上限基本都是O(nlog(n)) 时间对比 排序方法 平均情况 最好情况 最坏情况 辅助空间 稳定性...
</p>
</div>
</a>
<a href="/github-io/2018-07-16/CAL-01_KMP" class="catalogue-item">
<div>
<time datetime="2018-07-16 00:00:00 +0800" class="catalogue-time">July 16, 2018</time>
<h1 class="catalogue-title">模式匹配之KMP算法</h1>
<div class="catalogue-line"></div>
<p>
#问题描述 模式匹配:字串的定位操作通常被称为串的模式匹配 最简单的模式匹配方式:从主串S的第pos个字符起和模式的第一个字符比较之,若相等,则继续逐个比较后续字符;否则从主串S的下一个字符起再重新和模式的字符比较之。依次类推,直至模式T中的每个字符依次和主串S中的一个连续的字符序列相等,则称匹配成功,函数值为和模式T中第一个字符相等的字符在主串中的序号,否则称匹配失败。 模式匹配的改进算法 D.E.Knuth 、V.R.Pratt 和 J.H.Morris同时发现,其算法的本质改变在于:每当一趟匹配过程中出现字符比较不等时,不需要回溯指针,而是利用已经得到的部分匹配结果将模式向右移动尽可能远的一段距离后,继续进行比较。 在此不对算法本身做太多阐述,网上有很多说明,仅仅是,完成我自己在理解此算法之后,写出相应的代码。 求next与nextval与匹配...
</p>
</div>
</a>
<a href="/github-io/2018-07-10/C-01_HelloWorld" class="catalogue-item">
<div>
<time datetime="2018-07-10 00:00:00 +0800" class="catalogue-time">July 10, 2018</time>
<h1 class="catalogue-title">C and C++ HelloWorld</h1>
<div class="catalogue-line"></div>
<p>
第一篇博客 关于 Hello World C #include<stdio.h> int main(){ printf("HelloWorld"); return...
</p>
</div>
</a>
<a href="/github-io/2016-10-18/very-long-title-post" class="catalogue-item">
<div>
<time datetime="2016-10-18 00:00:00 +0800" class="catalogue-time">October 18, 2016</time>
<h1 class="catalogue-title">For Example of very Long Title Would Be Typography Elements in One</h1>
<div class="catalogue-line"></div>
<p>
NOTE: This markdown cheatsheet is a typography demo for this...
</p>
</div>
</a>
</div>
<div class="catalogue">
<a href="/github-io/2020-11-16/R-05" class="catalogue-item">
<div>
<time datetime="2020-11-16 00:00:00 +0800" class="catalogue-time">November 16, 2020</time>
<h1 class="catalogue-title">如何用 R Markdown 生成每周实验报告</h1>
<div class="catalogue-line"></div>
<p>
背景 本科时,我主要交作业的报告,写成 HTML 文件,再转 PDF ,追求“花里胡哨”,让别人看起来很“认真”、很“高端”的感觉。用 Prettydoc写完全没问题,网页很容易加入特效。但 HTML 打印输出结果时,相信很多人都会遇到打印不完整的情况。转变为研究生和博士之后,有时依然需要每周给导师写报告。这时候,还像交作业一样给导师交花里胡哨的 HTML...
</p>
</div>
</a>
<a href="/github-io/2019-10-01/R-04" class="catalogue-item">
<div>
<time datetime="2019-10-01 00:00:00 +0800" class="catalogue-time">October 01, 2019</time>
<h1 class="catalogue-title">记一次 Prettydoc 的改造</h1>
<div class="catalogue-line"></div>
<p>
声明 本文的出发点并不是鼓励去“剽窃” Prettydoc 包的成果,而是给一种比较小代价改造模板的流程介绍。 写文章有两种观点,一种叫天下文章一大抄,一种叫站在巨人的肩上可以看得更远。前者在抄袭的道路上越走越远,后者推陈出新发明出更多很有意思的事。(这里希望夹带一些私货,仅之前在统计之都发表了一篇关于 R Markdown 的文章,却发现各种平台未经允许直接转载,甚至有的转载不附加链接,这里必须澄清一点,不是在我个人博客或是统计之都看到我写的统计文章都属于抄袭,请联系本人,将采用发律手段解决。) 本文希望基于一个创作 R...
</p>
</div>
</a>
<a href="/github-io/2019-06-14/R-03" class="catalogue-item">
<div>
<time datetime="2019-06-14 00:00:00 +0800" class="catalogue-time">June 14, 2019</time>
<h1 class="catalogue-title">基于 R Markdown 的展示模板创建和使用</h1>
<div class="catalogue-line"></div>
<p>
背景介绍 英语演讲课曾说,幻灯片只是辅助工具,更核心和本质的是演讲者的内容。报告和幻灯片,其本质都是服务于展示知识这个过程,两者有着相通之处,利用 R Markdown 可以特别方便地将一份课程报告转化为课程答辩幻灯片,展示幻灯片填充些内容也就是总结的报告,这四年来,利用两者的转换关系,为我节约了不少时间。 作为排版困难者,我尝试着探索了一些只关注内容的幻灯片和报告的写法,随着四年统计学习,R虽然已经快脱离我的常用语言名单,但我那利用 R Markdown 制作幻灯片和课程报告的经验还是不希望就随着我的不用而消亡。故记录下一些改装模板的经验。本文适合会 R...
</p>
</div>
</a>
<a href="/github-io/2018-04-10/R-02" class="catalogue-item">
<div>
<time datetime="2018-04-10 00:00:00 +0800" class="catalogue-time">April 10, 2018</time>
<h1 class="catalogue-title">“神抽”还是“鬼抽”?炉石发牌员偏好探究</h1>
<div class="catalogue-line"></div>
<p>
背景介绍 《炉石传说》是一款集换式卡牌游戏,玩家根据自己现有的卡牌组建合适的卡组,驱动随从,施展法术,与对手一决高下。而作为一款卡牌游戏,除了自身收藏卡牌之外,取得胜负最为关键的一点在于,关键时候是否能抽到关键的卡牌。不少玩家吐槽炉石传说可能存在一个发牌员,为了增加玩家的游戏时间,对发牌机制做了控制,以达到鬼抽/神抽的目的。而实际上,炉石暗地里调整各种选牌概率也不是第一次了。例如:著名的竞技场11只剑龙骑术,极大的降低了玩家的用户体验。 笔者学习《实验设计》课程中,便希望能利用上课知识,为了验证网络上一直以来对发牌员偏好的猜测,开始了简单的实验。研究游戏动态过程过于复杂,所以以起手发牌换牌为例,完成一次简单的探究——炉石中的起手发牌规律。 一、实验设计 1.数据说明,为了探究抽牌上手的因素,将因变量确定为以下几类: 名称 数据记作 备注 “上手卡牌顺序” 记为”次序”...
</p>
</div>
</a>
<a href="/github-io/2018-03-12/R-01" class="catalogue-item">
<div>
<time datetime="2018-03-12 00:00:00 +0800" class="catalogue-time">March 12, 2018</time>
<h1 class="catalogue-title">空间多维数据展示--涟漪图</h1>
<div class="catalogue-line"></div>
<p>
1. 研究问题 1.1研究问题背景 多年来,全国雾霾爆发,在地理空间上是否存在规律?2017年全国数学建模大赛提出给“拍照赚钱”任务定价,数据是否在位置上呈现一些规律?越来越多的研究定位在空间数据之上。 多维数据存在着展示上不直观的特点,数据容易“纠缠在一起”,想看出数据的变化规律、空间分布规律存在一定的障碍,通常人们将多维数据投影到二维上,但数据的“纠缠”仍然是比较难解决的,而展示多维数据的变化规律需要有一种能动态变化可视化手段。在看到水滴产生的涟漪、画画时颜色的相互交融时,突发灵感,提出一种新的可视化图——涟漪图。 1.2研究问题说明 多维分类型数据,分类的展示可以用点图轻松展示,但无法体现出多维分类数据的每一个分类的紧密程度,哪些分类间存在着“纠缠”,以及数据变化的主要方向。总的来说,多维数据是不能简单用每个维度的均值来衡量的,于是需要一种动态化展示的方法。 1.3数据说明 本次作业为了降低采集数据成本,使用2017年全国数学建模大赛的部分数据集,但制作涟漪图的核心在于中心点如何选取,目前采用的是kmeans方法,选取核心点,所以核心数据仅剩下两部分,经度、维度。对任意数据集,都可以使用二维投射,将点放置到二位图像中。 2....
</p>
</div>
</a>
</div>
<div class="catalogue">
<a href="/github-io/2022-03-02/Spark-01" class="catalogue-item">
<div>
<time datetime="2022-03-02 00:00:00 +0800" class="catalogue-time">March 02, 2022</time>
<h1 class="catalogue-title">记配置n遍spark多机分布式环境</h1>
<div class="catalogue-line"></div>
<p>
背景 最近由于论文的关系,设计的算法需要在分布式环境下,测试算法的通信时间通信代价,于是尝试配置了多台机器的分布式环境。由于配置过程较为复杂,其中也遇到许许多多问题,由于各式各样的因素,不得不一直转换不同的环境,完成机器的配置。虽然由于水平不足,犯了许多不必要的配置错误,有的问题看起来比较愚蠢,但为了之后避免踩入相同的坑,也就将这一路以来,不断配置更新的过程写成文章,以方便查找。 配置20遍 最初使用的平台是人大校级计算平台,在这个平台上,可以申请一定数量的机器,然后以科研结果作为经费抵扣。使用此平台的原因是之前有前辈在上面配置过 Spark 环境,而我有一定机会可以直接利用他配置好的成果,然而事情并没有像我想象的那么简单。此时出现了两个主要的问题,其一是该环境并没有真正配置yarn,并不能做到真正的并行;其次实际上此平台的集群是在一个大机器上分割出的小虚拟机组成集群,这样的集群实际上的通信代价是非常低的,这无法体现出我们算法的优势,因此我不得不寻找其他平台。之后就在组里先找了6台服务器,直接利用这6台服务器搭建一个集群,虽然机器数目少一点,但平摊下来,每个机器都比原来的配置要更好。当然事情不会那么顺利,由于我实验操作的数据量极大,我不断试探服务器计算能力的上限,最终这些服务器也难堪重负,纷纷内存耗尽、磁盘耗尽,引发了一系列不好的连锁反应,究其原因是我没有做docker环境隔离(要学的东西还很多)。由于当时论文ddl在即,让我只能在夜间跑代码,完全是不可能完成目标的,因此我不得不使用阿里云下的服务器。之后就搞了16台阿里云服务器,并在上面配置真·分布式环境,此时我已经有了十次左右配置环境的经验,但哪怕如此,又经历了经费不足、神秘bug等等意想不到的问题,但我最终还是勉强完成了论文,初次投稿当然还是被拒了。之后改投论文的过程中,吸取了服务器可能很容易崩,随时可能换机器的现实,尽可能地将许多作业改为了批处理,终于又配置了很多次,最终完成了实验和论文。 分布式环境的成分 HDFS 虽然说使用 Spark...
</p>
</div>
</a>
<a href="/github-io/2020-06-28/C-Python-05_read_graph" class="catalogue-item">
<div>
<time datetime="2020-06-28 00:00:00 +0800" class="catalogue-time">June 28, 2020</time>
<h1 class="catalogue-title">读取Graph数据的代码</h1>
<div class="catalogue-line"></div>
<p>
背景 记录读图的一些代码,由于图一般都会储存为稀疏矩阵的形式,否则大图根本无法储存,所以最终返回的都是稀疏矩阵,比较节约空间的是csr matrix。 CSR Matrix and COO Matrix COO Matrix...
</p>
</div>
</a>
<a href="/github-io/2020-06-16/Python-04_pre_picture" class="catalogue-item">
<div>
<time datetime="2020-06-16 00:00:00 +0800" class="catalogue-time">June 16, 2020</time>
<h1 class="catalogue-title">一些乱七八糟的图片处理</h1>
<div class="catalogue-line"></div>
<p>
背景 记录一些摸索图片处理过程中,看到的,和自己研究的图片预处理方法 图片移动 # 给定判断函数的批量图片移动 import shutil import os def...
</p>
</div>
</a>
<a href="/github-io/2020-02-29/Python-03_Kmeans_with_Cython" class="catalogue-item">
<div>
<time datetime="2020-02-29 00:00:00 +0800" class="catalogue-time">February 29, 2020</time>
<h1 class="catalogue-title">Kmeans base on Cython</h1>
<div class="catalogue-line"></div>
<p>
背景 Kmeans 是机器学习比较基础的算法,利用包调用比较容易,未来的算法可以很复杂,但基础都是一样简单的。算法层面尽量写得简单,将优化过程尽量写复杂。由于想使用Cython,先写C++部分,这里需要定义命名空间。头文件代码如下: 代码 KMeans.h #ifndef KMEANS #define KMEANS #include...
</p>
</div>
</a>
<a href="/github-io/2020-02-19/Python-02_sort_img" class="catalogue-item">
<div>
<time datetime="2020-02-19 00:00:00 +0800" class="catalogue-time">February 19, 2020</time>
<h1 class="catalogue-title">整理提取图片始</h1>
<div class="catalogue-line"></div>
<p>
背景 这一切要从我清理手机开始说起,最大占用手机空间的内容当然是手机上的照片。糟糕的是,将照片传到计算机之后,照片就完全乱了,虽然之前也是一团乱麻。想到之前想存图片当壁纸,存了几万张照片,这次可以总结一下,用python对图片做些简单的分类。所以总的说,目标是尽可能提取高清的图片作为壁纸,必要时需要按风格分一下类。其次是手机上不需要的图片且质量差的,或者是无法打开的照片都清理掉。下面是清理过程中的代码: 简单整理图片的思路与实现 准备部分 #与图像处理相关的包 from PIL import Image import...
</p>
</div>
</a>
<a href="/github-io/2018-07-15/Python-01_base" class="catalogue-item">
<div>
<time datetime="2018-07-15 00:00:00 +0800" class="catalogue-time">July 15, 2018</time>
<h1 class="catalogue-title">Python base skill</h1>
<div class="catalogue-line"></div>
<p>
标准数据类型 与其他语言十分不一样的是python 封装的几种数据类型 六种数据类型 Number 不用理会浮点型、整数型、为计算带来很多方便,当然不足之处还是运算比较慢,容易不精准计算 String 字符串 从String库提供的字符串处理函数来说,python String相对于其他语言十分的方便和友好...
</p>
</div>
</a>
</div>
<div class="catalogue">
<a href="/github-io/2022-03-02/Spark-01" class="catalogue-item">
<div>
<time datetime="2022-03-02 00:00:00 +0800" class="catalogue-time">March 02, 2022</time>
<h1 class="catalogue-title">记配置n遍spark多机分布式环境</h1>
<div class="catalogue-line"></div>
<p>
背景 最近由于论文的关系,设计的算法需要在分布式环境下,测试算法的通信时间通信代价,于是尝试配置了多台机器的分布式环境。由于配置过程较为复杂,其中也遇到许许多多问题,由于各式各样的因素,不得不一直转换不同的环境,完成机器的配置。虽然由于水平不足,犯了许多不必要的配置错误,有的问题看起来比较愚蠢,但为了之后避免踩入相同的坑,也就将这一路以来,不断配置更新的过程写成文章,以方便查找。 配置20遍 最初使用的平台是人大校级计算平台,在这个平台上,可以申请一定数量的机器,然后以科研结果作为经费抵扣。使用此平台的原因是之前有前辈在上面配置过 Spark 环境,而我有一定机会可以直接利用他配置好的成果,然而事情并没有像我想象的那么简单。此时出现了两个主要的问题,其一是该环境并没有真正配置yarn,并不能做到真正的并行;其次实际上此平台的集群是在一个大机器上分割出的小虚拟机组成集群,这样的集群实际上的通信代价是非常低的,这无法体现出我们算法的优势,因此我不得不寻找其他平台。之后就在组里先找了6台服务器,直接利用这6台服务器搭建一个集群,虽然机器数目少一点,但平摊下来,每个机器都比原来的配置要更好。当然事情不会那么顺利,由于我实验操作的数据量极大,我不断试探服务器计算能力的上限,最终这些服务器也难堪重负,纷纷内存耗尽、磁盘耗尽,引发了一系列不好的连锁反应,究其原因是我没有做docker环境隔离(要学的东西还很多)。由于当时论文ddl在即,让我只能在夜间跑代码,完全是不可能完成目标的,因此我不得不使用阿里云下的服务器。之后就搞了16台阿里云服务器,并在上面配置真·分布式环境,此时我已经有了十次左右配置环境的经验,但哪怕如此,又经历了经费不足、神秘bug等等意想不到的问题,但我最终还是勉强完成了论文,初次投稿当然还是被拒了。之后改投论文的过程中,吸取了服务器可能很容易崩,随时可能换机器的现实,尽可能地将许多作业改为了批处理,终于又配置了很多次,最终完成了实验和论文。 分布式环境的成分 HDFS 虽然说使用 Spark...
</p>
</div>
</a>
<a href="/github-io/2018-07-15/Java-01_HelloWorld" class="catalogue-item">
<div>
<time datetime="2018-07-15 00:00:00 +0800" class="catalogue-time">July 15, 2018</time>
<h1 class="catalogue-title">Java HelloWorld</h1>
<div class="catalogue-line"></div>
<p>
Java HelloWorld //Helloworld.java public class HelloWorld{ public static void main(String...
</p>
</div>
</a>
<a href="/github-io/2018-06-11/EJB-01-Ant-demo" class="catalogue-item">
<div>
<time datetime="2018-06-11 00:00:00 +0800" class="catalogue-time">June 11, 2018</time>
<h1 class="catalogue-title">EJB——Ant Demo——simple package</h1>
<div class="catalogue-line"></div>
<p>
背景 简单的java情况下,使用命令行编译运行一个jar包的demo 目录结构 C:. │ mymanifest │ run.bat │ runjar.bat...
</p>
</div>
</a>
</div>
<div class="catalogue">
</div>
<div class="catalogue">
</div>
<!--article class="article">
<header>
<figure>
<img src="img/news-1.jpg" alt="" />
<noscript><img src="img/news-1.jpg"/></noscript>
<figcaption>- Sad</figcaption>
</figure>
<div class="meta-data">
<h3><a href="#">Default Post</a></h3>
<p class="author">
<time datetime="2015-08-07">November 17th, 2015</time>
</p>
<div class="socbtn">
<span class="share"><i class="icon-share"></i></span>
<div class="popup">
<a class="share--googleplus" href="#"><i class="icon-gplus-circled"></i></a>
<a class="share--twitter" href="#"><i class="icon-twitter-circled"></i></a>
<a class="share--facebook" href="#"><i class="icon-facebook-circled"></i></span></a>
</div>
</div>
</div>
</header>
<div class="entry-content" id="info">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vulputate eros ac posuere efficitur. Nunc bibendum cursus convallis. Praesent aliquam gravida lacus, a pharetra lorem dignissim ac. Vivamus at elit quam. Proin eu libero vel dolor bibendum lacinia.</p>
<p>Type is all set with the <code>rems</code>, so font-sizes and spacial relationships can be responsively sized based on a single <code><html></code> font-size property. Out of the box, Skeleton never changes the <code><html></code> font-size, but it's there in case you need it for your project. All measurements are still base 10 though so, an <code><h1></code> with <code>5.0rem</code>font-size just means <code>50px</code>.</p>
<p>Buttons come in two basic flavors in Skeleton. The standard <code><button></code> element is plain, whereas the <code>.button-primary</code> button is vibrant and prominent. Button styles are applied to a number of appropriate form elements, but can also be arbitrarily attached to anchors with a <code>.button</code> class.</p>
<p>Code styling is kept basic – just wrap anything in a <code><code></code> and it will appear like <code>this</code>. For blocks of code, wrap a <code><code></code> with a <code><pre></code>.</p>
<p>Paragraph with <strong>bold</strong>, <i>italic</i> and <a href="#">link</a> styles.</p>
</div>
<footer>
<ul class="tags">
<li><a href="#" class="tag">HTML</a></li>
<li><a href="#" class="tag">CSS</a></li>
<li><a href="#" class="tag">JavaScript</a></li>
<li><a href="#" class="tag">Sketch 3</a></li>
<li><a href="#" class="tag">Kirby</a></li>
</ul>
</footer>
</article-->
<!--article class="article">
<header>
<div class="quote">
<p class="line-through"><span><a href="#">Quote Custom Post</a></span></p>
<div class="stripe-border">
<blockquote>
<p>“If you can’t explain it simply, you don’t understand it well enough.” </p>
</blockquote>
</div>
<cite class="line-through"><span>Albert Einstein</span></cite>
</div>
<div class="meta-data">
<p class="author">
<time datetime="2015-08-07">November 5th, 2015</time>
</p>
<div class="socbtn">
<span class="share"><i class="icon-share"></i></span>
<div class="popup">
<a class="share--googleplus" href="#"><i class="icon-gplus-circled"></i></a>
<a class="share--twitter" href="#"><i class="icon-twitter-circled"></i></a>
<a class="share--facebook" href="#"><i class="icon-facebook-circled"></i></span></a>
</div>
</div>
</div>
</header>
<div class="entry-content" id="info">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vulputate eros ac posuere efficitur. Nunc bibendum cursus convallis. Praesent aliquam gravida lacus, a pharetra lorem dignissim ac. Vivamus at elit quam. Proin eu libero vel dolor bibendum lacinia.</p>
<p>Type is all set with the <code>rems</code>, so font-sizes and spacial relationships can be responsively sized based on a single <code><html></code> font-size property. Out of the box, Skeleton never changes the <code><html></code> font-size, but it's there in case you need it for your project. All measurements are still base 10 though so, an <code><h1></code> with <code>5.0rem</code>font-size just means <code>50px</code>.</p>
<p>Buttons come in two basic flavors in Skeleton. The standard <code><button></code> element is plain, whereas the <code>.button-primary</code> button is vibrant and prominent. Button styles are applied to a number of appropriate form elements, but can also be arbitrarily attached to anchors with a <code>.button</code> class.</p>
<p>Code styling is kept basic – just wrap anything in a <code><code></code> and it will appear like <code>this</code>. For blocks of code, wrap a <code><code></code> with a <code><pre></code>.</p>
<p>Paragraph with <strong>bold</strong>, <i>italic</i> and <a href="#">link</a> styles.</p>
</div>
<footer>
<ul class="tags">
<li><a href="#" class="tag">Albert</a></li>
<li><a href="#" class="tag">Science</a></li>
<li><a href="#" class="tag">Minimal</a></li>
<li><a href="#" class="tag">Kirby</a></li>
</ul>
</footer>
</article>
<article class="article">
<header>
<div class="video-item">
<a class="swipebox-video" rel="vimeo" href="https://www.youtube.com/watch?v=vt79JcPfZQA">
<div class="block-blur"></div>
<div class="mask">
<figure>
<img src="img/news-2.jpg"/>
<noscript><img src="img/news-2.jpg"/></noscript>
<div class="icon">
<svg width="64" height="64" viewBox="0 0 510 510" fill="#fff">
<path d="M204 369.75L357 255 204 140.25v229.5zM255 0C114.75 0 0 114.75 0 255s114.75 255 255 255 255-114.75 255-255S395.25 0 255 0zm0 459c-112.2 0-204-91.8-204-204S142.8 51 255 51s204 91.8 204 204-91.8 204-204 204z"/>
</svg>
</div>
</figure>
</div>
</a>
</div>
<div class="meta-data">
<h3><a href="#">Youtube Video Custom Post</a></h3>
<p class="author">
<time datetime="2015-08-07">October 21th, 2015</time>
</p>
<div class="socbtn">
<span class="share"><i class="icon-share"></i></span>
<div class="popup">
<a class="share--googleplus" href="#"><i class="icon-gplus-circled"></i></a>
<a class="share--twitter" href="#"><i class="icon-twitter-circled"></i></a>
<a class="share--facebook" href="#"><i class="icon-facebook-circled"></i></span></a>
</div>
</div>
</div>
</header>
<div class="entry-content" id="info">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vulputate eros ac posuere efficitur. Nunc bibendum cursus convallis. Praesent aliquam gravida lacus, a pharetra lorem dignissim ac. Vivamus at elit quam. Proin eu libero vel dolor bibendum lacinia.</p>
<p>Type is all set with the <code>rems</code>, so font-sizes and spacial relationships can be responsively sized based on a single <code><html></code> font-size property. Out of the box, Skeleton never changes the <code><html></code> font-size, but it's there in case you need it for your project. All measurements are still base 10 though so, an <code><h1></code> with <code>5.0rem</code>font-size just means <code>50px</code>.</p>
<p>Buttons come in two basic flavors in Skeleton. The standard <code><button></code> element is plain, whereas the <code>.button-primary</code> button is vibrant and prominent. Button styles are applied to a number of appropriate form elements, but can also be arbitrarily attached to anchors with a <code>.button</code> class.</p>
<p>Code styling is kept basic – just wrap anything in a <code><code></code> and it will appear like <code>this</code>. For blocks of code, wrap a <code><code></code> with a <code><pre></code>.</p>
<p>Paragraph with <strong>bold</strong>, <i>italic</i> and <a href="#">link</a> styles.</p>
</div>
<footer>
<ul class="tags">
<li><a href="#" class="tag">Video</a></li>
<li><a href="#" class="tag">Software</a></li>
<li><a href="#" class="tag">Engineer</a></li>
<li><a href="#" class="tag">Kirby</a></li>
</ul>
</footer>
</article>
<article class="article">
<header>
<div class="gallery">
<div class="img_box blur pic">
<a rel="gallery-1" href="img/news-4.jpg" class="swipebox-gallery">
<img src="img/thumb-1.jpg" alt="image">
<noscript><img src="img/thumb-1.jpg"/></noscript>
</a>
</div>
<div class="img_box blur">
<a rel="gallery-1" href="img/news-5.jpg" class="swipebox-gallery">
<img src="img/thumb-2.jpg" alt="image">
<noscript><img src="img/thumb-2.jpg"/></noscript>
</a>
</div>
<div class="img_box blur">
<a rel="gallery-1" href="img/news-6.jpg" class="swipebox-gallery">
<img src="img/thumb-3.jpg" alt="image">
<noscript><img src="img/thumb-3.jpg"/></noscript>
</a>
</div>
<div class="img_box blur">
<a rel="gallery-1" href="img/news-7.jpg" class="swipebox-gallery">
<img src="img/thumb-4.jpg" alt="image">
<noscript><img src="img/thumb-4.jpg"/></noscript>
</a>
</div>
<div class="img_box blur">