complex small world

どうしようもない日々の追想

RNN調査 ver1

今更感がかなりあるものの、、RNN: Recurrent Neural Networkって面白そうだなと思い、CharRNNのソースに触れてみた。 オリジナルはこちら。chainerバージョンです(chainer-char-rnn)。有り難く使わせて頂きました。 github.com

いきなりですが調査結果

  • 正直CPUでもGPUでもスピードにそんなに違いはない。やはりそこがRNNの課題点?
  • CharRNNはpython2で組まれてるので注意。
  • 実行環境はwindows/x64/GPU/Python3.5(3.5用に少し改変)

テスト実行にあたってのログ

Train:(CPU)

$python train.py

Train:(GPU)

$python train.py --gpu 0

  • 学習ではCVフォルダが生成され、その中にチェックポイントでのモデルファイルがセーブされていく

Test:(CPU):

  • vocalファイルと、モデル、最初の一字を少なくとも指定する(word-seqモデルなので最初の1字だけ指定すればいい) $python sample.py --vocabulary data/tinyshakespeare/vocab.bin --model cv/charrnn_epoch_0.04.chainermodel --primetext hello

すると最初に生成されたモデルはこんな感じ

helloa  oaeTa
nehnreyttffpmywa e  pree
n nlg
ds e. 
qocs,oo  eaAoaopdmrh toslpyiootta aoeRler eaGehoate Cfass dmome et, oo
iDN eoMPzdlnhtokTrn nor Mo:huramth  dsdlannhoroh Rhourk,lsrteeos hnhioWo aediciunsordGhosadrh
n,e
 e. nD I;s
oer s hlr Topi
P:sfTem, nyetbcki 
rJ e s  p eiefto pilishrab.ybnAegtI.vspiyir .eoo od en'oNo
ifN reeki?aRaleeehe LLny  e l,a;e s troeotd  uo oaSo uh ,nh  gdha nhdirC;
 e n mn ' lra

rre;cew tek
 b, OD
,
es  etgspnee. iMSCcsslnag iiaM
:dL, kttw ae Zrdih rcyar n hswEM FDgbnh emsl
:eNo.';Ced
j:odnqs  t h
iEaraetoyd ffaehpiokot
hs,tfe ciuf.oith

eCUobuS?EANLSINrmgeonesfndoiiaa;lnpn esdtnbit IWtTho'ledc tn egna Ga sNbci h.:e ssght duhtT oobdo
hsig
ee,ehnmr:
 bM
s  
em
IX y?Te,ilruq
 pcdtlwratiohmsda ! r
u eolu  fhw
pholNIm e d usho,ewoOhotl dL  ..n tUlLwsrCgbkte  a
esoee eoimRo Dnyan br
  mertm- aryev Ifed  tg
h
dcEu i ne,hrgfoec.a-ymradsmwso: iew  uuas
ohSenudoettrrmerl  tbsa'dk dan.yvh
f
iontsniEeereii ,nityyueeheyoerslnqe e ciuee:n
e

dh owif e, 
i d   grnrotp aei r
 d
ie
csaethrWa:iedkwen.ern&etrt odr' tfd d lArtaFmeur rte
Iahr Do,irsiR K, xlttaror Nfo ns
rrarf to ntssrouhgtsnkhoteaeioaat eese
uoe'oj.avD y'ihrYpti,tLsknlhmna r ie
iiasr
hH sr si tie, ayi;tae.G .oTyc y mTi;e
g, smuke

eehh.AkehTIEra  ku Btilafreetttos I hoeos
H
CE.Lki'GANj$nopt
 AnrilAbren.  utput ahg ote ehhas I:difarseI i,molt iolwradt,le o!yhhgh     'grrmo nrTthgaroskdItnosaoeehe!Rrlarg,,vv Lrlnm uhrSmwaent
,ot,yihk
ermie S:RsRudef nhpalr yedly'tuairifheitI .eo
te$o:o oys  u'episedctsLe
sNhonr kpttewofkkmae grwm Tl  lstotooo ,b k ehtresrot yrP oh   eyatnauctk eomda etyNhsanr3yp.ea
tod
tram'eImne ri  ytaynsyYehurrd,vto  yenm f,so,ulia oheamNo e. lrOsSooH!maatnesiiyn
 ost,iv 'r oLs,pcDeeop artiuNht d e f. odi o, l,ehm ssAfaeh,lcl. w cl
.iMHnkYt: heF  rf  Lesflht  M tnwtisdt d.be uaOsltuG hh vr  r h 
tww rap:lTubttZeoNcly.
HtY a,ynLtu atrhhth ooSoA
h hI:aoivheref ,  tyoa el lbi
dieiwn ho 'OtTwl rieinudyog lTinawEacLIW
.PedYul t:awwr
 yowo re o   te,ms w va srteutil  fe ah,haty ys

半分ぐらい学習が終わったモデルでは以下のような感じ。(ちなみに全部まで学習をやろうとしたがPCのメモリが他のアプリのせいで足らず、強制終了になってた。でも全部やってもlossが0.1~0.2ポイント減る程度なので、そんなに変わらない気も。) $python sample.py --vocabulary data/tinyshakespeare/vocab.bin --model cv/charrnn_epoch_27.66.chainermodel --primetext h

hello, though
you speak ofe, your heart too' are like a loanch,
When I have I mine eye of virtuo.
And we do seem his tacked blessed you.

GONZALO:
How hence, for I cause:
Ratclipp'd it from mine eye into this;
Weaking mortal obey'd on the grounds,
Sinking without think to fasting drat.

Gurkenman:
Ammatity is earth, peace, indeed,
if I may go but to full.

CAMILLO:
Since handly I have hath his bones the behind,
Come with a bush! Whose women will be drink.

First Senator:
No queen it, it is agais;
He speak only kneel befork the king.
And many heaving those words, I see
Would have many sound from you again,
Since, that ban me presence, God blessed withal
home before warice of mockets?

CAMILLO:
Sight, grabow, let's ere I had, soon again.

TRANIO:
Sir, Richard, I for Rome? woll, sir!
I do more the city Clifford with them
One I be deep! I am a recestive
Who bach as dinens and matter's house:
But I will before my loves on others
Finger and no more liberty, my lord,
Which we may not nature propire their dinner:
Nor my dears God to him that fly thither
to chance! Is right that he is deposes are thee:

CLIFFORD:
It were at one of old, any you shall,
Hither, you in rignion; tells trumpets!
O bleed'st unhailing, thou dest young El'res:
One import seeming here please yeavenl'd,
And neither was his trancals to my father.

WARWICK:
Yet, if that avour'd to thy sake, O my son?
He comes him. How, go, brother; but the lord. The suit
To say the king thee.
Since it is vile of King Romeo.

Tailor:
Dearly with the command vice but Mercutio
The frozen to e'ed wonder?

MOPSA:
I must no more Gyazen: hath have lengt to
the same as your own curses: 'enceal he.

ROMEO:
They'll so sister within mine. They pass, ne'er not
wantedience.

DUKE VINCENTIO:
It awaid's meetner traitors, more, Camior
will't make thy king for his deer,
What, the bound I mean, before my life;
There's cipusion and man not
Did it do morely.

Apotich:
If I'f angry, I have adon and draughtered
often: no very true great manly at t

すごい。文章っぽくなってる。意味は不明なものが多いですが。

XcodeでOpenCV処理する際の動画読み込みエラー

エラーその2

動画が読み込めない・・

(環境移行は中々大変・Windows懐かしや・・)

自分のテスト環境は以下

ヘッダーファイルのパスも通してます。 ライブラリも加えてます。 ( videoio.3.1.0, imageproc.3.1.0, highgui.3.1.0, core.3.1.0)

ビルドも成功したが、動画が読めん、というエラー。

原因は、相対パスではなく、絶対パスにしなきゃならない、というオチでした。

/Users/...からちゃんと書きましょう。。

XcodeでOpenCVの時のエラー

XcodeOpenCVの設定をしたものの、cv:named winowが素直に通らない。 こういうエラーが出た

dyld: Library not loaded: /usr/local/opt/webp/lib/libwebp.6.dylib Referenced from: /usr/local/opt/opencv3/lib/libopencv_imgcodecs.3.1.dylib

その時の解消法:webpをインストールする https://developers.google.com/speed/webp/docs/compiling#building

高校別の海外大学合格者ランキングなるもの

全くデータ解析の話ではないが、、気になったので。

//

3月の大学合格発表に伴って、日本のマスコミは「高校別東大合格者ランキング」なるものを我先と発表したがります。どうやらそれはお受験に関連する業界での1大イベントみたいです。

それが市民の関心に裏付けされたものだから、とても注目を集めているのだと思います。

自分も子供の親として、かなり関心があります。近所の高校はどうなんだろうとw。

 

でも、正直それだけでは何か苦しい。

自分自信、海外に1年間留学させてもらったことがあります。そこでは東大だろうがどこの日本の大学だろうが、同様に扱われます。そして日本人は、やはり英語とコミュニケーションに苦労しているなぁというのが率直な感想。そして中国人のたくましいこと。。

最近の若い子は、英語とプログラミングを身に付けるためにも、人生の早いフェーズで海外で挑戦して欲しい、これが僕の思いです。英語は日本で勉強するよりも、行っちゃえばイイじゃん、そういうスタンスなのです。

ただ日本の文化にある程度染まった子なら、そのベストなタイミングは、大学か大学院かな、と思います。 (もちろん個人の成績や家計の状況で行ける行けないはあると思います。)

 

Youtubeでこんなものを見つけました。

https://www.youtube.com/watch?v=g4IKZsAD6Uo

高校レベルでの海外大学進学者って、日本ではかなり珍しい存在だと思います。

(それこそインターナショナルスクールとか・)

ただ、ある程度の数を送り込む高校は、制度的に整備されているんだろうなと思います。

1位の加藤学園暁秀高校、知りませんでした。静岡の高校みたいですね。

2位の渋谷教育学園幕張、近年東大合格者数も凄い伸ばしてますが海外合格者も多いんですね。

そして3位は開成高校。さすがっすね。

見た感じ、国際バカレロア認定されてる高校や、SGH: スーパーグローバルハイスクール認定されてる高校が多いようですが、もっと母数が伸びて欲しい、そこまでの進学校でなくとも海外に行けるような体制があって欲しい、そう思いました。

ちゃんちゃん。