−目次
文書の過去の版を表示しています。
Kerasプログラミングの全体図
以下のような流れでプログラミング文を読んだり書いたりしていくと、分かりやすいと思います。
実際に自前データを動かそうとするときは、ある程度、pythonの勉強と、機械学習の勉強が必要だと思われます。
# train.py #1 Kerasを使用するためのimport文 #2 データ準備(Keras) #3 モデル設定(Keras) #4 モデル学習(Keras) #5 結果の出力(Keras) #6 学習結果の保存(Keras) # predict.py #7 推測(Keras) (1)#1 Chainerを使用するためのimport文 (2)#2 tuple_datasetによるデータの準備・設定 (3)#3 モデルの記述 class MyModel(Chain): def __init__(self): super(MyModel, self).__init__( # パラメータを含む関数の宣言 ) def __call__(self, x,t): # モデルを記述 (4)#4 モデルと最適化アルゴリズムの設定(ほぼお約束の3行) model = MyModel() optimizer = optimizers.Adam() optimizer.setup(model) (5)#5 学習(Trainerを利用する場合) iterator = iterators.SerialIterator(tdata, bsize) updater = training.StandardUpdater(iterator, optimizer) trainer = training.Trainer(updater, (ep, ‘epoch’)) trainer.extend(extensions.ProgressBar()) trainer.run() (6)#6 結果の出力
参考文献
初めてKerasプログラミングをやるときは、以下の2つの本がおすすめです。ゼロから作るDeep LearningでPythonの基本と理論を学び、詳解 ディープラーニングで、Kerasでの実装方法を学ぶのがよいと思われます。
<html>
<iframe style=“width:120px;height:240px;” marginwidth=“0” marginheight=“0” scrolling=“no” frameborder=“0” src=“rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=twosquirrel-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4873117585&linkId=13a7db2c19cc5f40d6ab48906de8abd1”></iframe>
<iframe style=“width:120px;height:240px;” marginwidth=“0” marginheight=“0” scrolling=“no” frameborder=“0” src=“rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=twosquirrel-22&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4839962510&linkId=d722909965b5eab4196d370757843f6f”></iframe>
</html>
Keras公式GitHub
keras/examples/mnist_mlp.py
Branch:keras-2
https://github.com/fchollet/keras/blob/keras-2/examples/mnist_mlp.py
kerasのmnistのサンプルを読んでみる
ash8h
2017年07月29日に投稿
https://qiita.com/ash8h/items/29e24fc617b832fba136
次節以降
MNISTを例に、一つずつ解説させていただきたいと思います。
いつもあまり面白くないMNISTですが、Kerasプログラミングを理解する上で避けて通れないので、頑張ってやってみたいと思います。
リンク
目次