※当サイトの記事には、広告・プロモーションが含まれます。

転移学習(TL:Transfer Learning)とFine Tuningの違いって?

f:id:ts0818:20210215204653j:plain

xtech.nikkei.com

 人工知能(AI)の能力が人間を上回る領域が、より高度かつ複雑な方向へ拡大を続けている。2019年10月末には英ディープマインドDeepMind)のAIが米ブリザードエンターテインメント(Blizzard Entertainment)のオンライン戦略ゲーム「StarCraft II」の対戦で大きな成果を上げたことが、欧米で話題となった。囲碁よりもオンライン戦略ゲームで人間に勝つことの方が、現実世界でのAI活用を目指す上で重要とされているためだ。

グーグルのAIが「対戦ゲーム」で人間を倒した、囲碁での勝利より画期的な理由 | 日経クロステック(xTECH)

⇧ 地球外生命体が地球を侵略しに来るような事態が起こりえたとしても、AIが防衛してくれるっていうことですかね、夢広がりますね、どうもボクです。

ということで、「多層ニューラルネットワーク」とかが絡んでくる「深層学習(DL:Deep Learning)」なんかの「学習」の手法とかについて調べてみました。

レッツトライ~。

 

転移学習(TL:Transfer Learning)って?

Wikipediaさんに聞いてみる。

Transfer learning (TL) is a research problem in machine learning (ML) that focuses on storing knowledge gained while solving one problem and applying it to a different but related problem. For example, knowledge gained while learning to recognize cars could apply when trying to recognize trucks. This area of research bears some relation to the long history of psychological literature on transfer of learning, although formal ties between the two fields are limited. From the practical standpoint, reusing or transferring information from previously learned tasks for the learning of new tasks has the potential to significantly improve the sample efficiency of a reinforcement learning agent.

https://en.wikipedia.org/wiki/Transfer_learning

⇧ 超ザックリ捉えると、「学習」した結果を再利用して「学習」させていく感じみたいですね。「強化学習」にも影響を与えられる可能性があると。

「転移学習(TL:Transfer Learning)」の定義は、

The definition of transfer learning is given in terms of domains and tasks. A domain  consists of: a feature space  and a marginal probability distribution , where . Given a specific domain, , a task consists of two components: a label space  and an objective predictive function . The function  is used to predict the corresponding label  of a new instance . This task, denoted by , is learned from the training data consisting of pairs , where  and .

https://en.wikipedia.org/wiki/Transfer_learning

⇧ って感じで、まぁ、よく分からん感じなんだけど、

Given a source domain  and learning task , a target domain and learning task , where , or , transfer learning aims to help improve the learning of the target predictive function  in  using the knowledge in  and .

https://en.wikipedia.org/wiki/Transfer_learning

⇧「転移学習(TL:Transfer Learning)」 の目的って言うのは、「予測関数(おそらくく目的関数)」の「学習」を改善することですと。

「転移学習(TL:Transfer Learning)」のアルゴリズムは、 

Algorithms are available for transfer learning in Markov logic networks and Bayesian networks.

https://en.wikipedia.org/wiki/Transfer_learning

⇧「Markov logic networks」と「Bayesian networks」のみで適応可能ってことですかね。

「転移学習(TL:Transfer Learning)」としては、 

www.mi.t.u-tokyo.ac.jp

ドメイン適応(Domain Adaptation)は,転移学習(Transfer Learning)と呼ばれる学習手法の一種です.十分な教師ラベルを持つドメイン(Source Domain,ソースドメイン)から得られた知識を,十分な情報がない目標のドメイン(Target Domain, ターゲットドメイン)に適用することで,目標ドメインにおいて高い精度で働く識別器などを学習します(ここで、ドメイン(Domain)とは,データの集まりを指す言葉です).

Domain Adaptation - 東京大学 先端科学技術研究センター 原田研究室

⇧「ドメイン学習(Domain Adaptation)」って手法があるそうな、というか、それ以外にも手法があるのかもしらんが、調べ方が分からん...

 

iandco.jp

⇧ 上記サイト様によりますと、「マルチタスク学習(Multitask Learning)」も「転移学習(TL:Transfer Learning)」ってことらしい。

 

Fine Tuningって?

Wikipediaさんに聞いてみるも、

In theoretical physicsfine-tuning is the process in which parameters of a model must be adjusted very precisely in order to fit with certain observations.

https://en.wikipedia.org/wiki/Fine-tuning

Although fine-tuning was traditionally measured by ad hoc fine-tuning measures, such as the Barbieri-Giudice-Ellis measure, over the past decade many scientists recognized that fine-tuning arguments were a specific application of Bayesian statistics.

https://en.wikipedia.org/wiki/Fine-tuning

⇧ とあるように、どうも「theoretical physics」における「Fine Tuning」についての言及であって、「機械学習(ML:Machine Learning)」や「深層学習(DL:Deep Learning)」についての「Fine Tuning」は言及してくれてない模様。

ネット検索してたら、

arXiv(アーカイヴ、archiveと同じ発音)は、物理学数学計算機科学定量生物学、計量ファイナンス統計学の、プレプリントを含む様々な論文が保存・公開されているウェブサイトである。論文のアップロード(投稿)、ダウンロード(閲覧)ともに無料で、論文はPDF形式である。1991年にスタートして、プレプリント・サーバーの先駆けとなったウェブサイトである。大文字の X をギリシャ文字カイ(Χ)にかけて archive と読ませている。

arXiv - Wikipedia

現代(2019年)においてはこうした仕組みのサイトは特に珍しいものでもない。しかし、arXivの設立当初(1990年代初頭)においては、学術出版社大学図書館を介さずに研究者同士がインターネットを介して直接に論文をやりとりできる場として、学術出版関係者に大きな驚きをもって受けとめられた。

arXiv - Wikipedia

2015年8月現在106万報以上の論文が保存されている。毎月8,000報を超える論文が追加されている。1991年、LANL preprint archiveという名称でロスアラモス国立研究所を運営元としてスタートし、1999年にarXiv.orgと改名。現在はコーネル大学図書館が運営元となっている。

arXiv - Wikipedia

⇧ って情報があって、

「CNN(Covolution Nueral Network)」の研究についてのPDFに「Fine Tuning」の説明があって、

Fine-tuning [6] modifies the parameters of an existing CNN to train a new task. The output layer is extended with randomly intialized weights for the new task, and a small learning rate is used to tune all parameters from their original values to minimize the loss on the new task. Sometimes, part of the network is frozen (e.g. the convolutional layers) to prevent overfitting. 

https://arxiv.org/pdf/1606.09282.pdf

⇧とあって、[6] は、

[6] R. Girshick, J. Donahue, T. Darrell, and J. Malik, “Rich feature hierarchies for accurate object detection and semantic segmentation,” in The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2014.

https://arxiv.org/pdf/1606.09282.pdf

⇧ ってあるから、2014年に開催された「IEEE」のカンファレンスの「Computer Vision and Pattern Recognition (CVPR)」の分野で定義された言葉ってことなんですかね?

で、「Fine Tuning」は、 

Feature extraction and fine-tuning are special cases of Domain Adaptation (when old and new tasks are the same) or Transfer Learning (different tasks). 

https://arxiv.org/pdf/1606.09282.pdf

⇧ まさかの「Domain Adaptation」や「Transfer Learning」における特殊なケースのことである、って言っておりますね。

というか「Domain Adaptation」って「Transfer Learning」の一種じゃなかったのか...

 

「転移学習(TL:Transfer Learning)」と「Fine Tuning」の違いって?

で、結局のところ、「転移学習(TL:Transfer Learning)」と「Fine Tuning」の違いって何なのよ? 

jinbeizame.hateblo.jp

ファインチューニングとは、学習済みモデルの一部もしくはすべての層の重みを微調整する手法です。転移学習では、学習済みモデルの重みを固定して用いますが、ファインチューニングでは学習済みモデルの重みを初期値とし、再度学習によって微調整します。

KelpNetで転移学習 - じんべえざめのノート

betashort-lab.com

転移学習とFine-Tuningの違いは、

  1. 転移学習:出力層だけを学習させるか
  2. Fine-Tuning:出力層以外も学習させるか

Pytorchで転移学習 | βshort Lab

⇧ 上記サイト様が分かりやすいです。

つまり、

  • 転移学習(Transfer Learning)
    学習済みモデルには手を加えず、学習を行い新たにモデルを作成
  • Fine Tuning
    学習済みモデルにも手を加えて、学習を行い新たにモデルを作成

ってことかと。

「学習済みモデル」をどう利用するかが異なるってことですかね。 

 

学習済みモデルは公開されている

CNN(Convolution Nueral Network)のように「ニューラルネットワーク」の層が深いものになってくると、性能の良いモデルを一から作るには計算処理のための莫大なのリソースとかが必要になってくるため、大学や企業の研究チームなどが「学習モデル」を公開してくれています。

ちなみに、「深層学習(DL:Deep Learning)」なんかでは「CPU」よりも「GPU」によって処理することが多いらしいです。

「CPU」と「GPU」の違いについては、

www.kagoya.jp

⇧ 上記サイト様が詳しいです。

 

話が脱線しましたが、「画像分類」の「学習モデル」なんかは、

pytorch.org

⇧ PyTorchの公式サイトで公開されてるっぽいです。

「PyTorch」が何なのかというと、

PyTorchは、コンピュータビジョン自然言語処理で利用されているTorch英語版を元に作られた、Pythonオープンソース機械学習ライブラリである。

PyTorch - Wikipedia

最初はFacebook人工知能研究グループAI Research lab(FAIR)により開発された。

PyTorch - Wikipedia

PyTorchはフリーでオープンソースのソフトウェアであり、修正BSDライセンスで公開されている。Pythonインターフェイスの方が洗練されており、活発に開発が行われているが、C++インターフェイスも存在する。

PyTorch - Wikipedia

PyTorchは次の2つの高度な機能を備えている

PyTorch - Wikipedia

⇧ ということみたいね。

ちなみに、

www.aist.go.jp

⇧ 日本でも「産総研(国立研究開発法人産業技術総合研究所)」とかが、「学習モデル」を公開してくれてる模様。

「PyTorch 」 は、環境構築が非常に面倒くさそうなのですが、何とGoogleさんが「Google Colaboratory(Colab)」という無料で利用できる環境を用意してくれております!

ただし、

qiita.com

90分ルールと12時間ルール

まず、最も重要なのがGoogle Colabには時間制限があるということです。

Google Colabの使い方まとめ - Qiita

⇧ というように、時間制限があるところが要注意ですかね。

Google Colaboratory(Colab)」は、Googleアカウントがあれば利用可能です。(Gmailとか使ってれば、Googleアカウントがあるということになるのですぐに使えますかね。) 

モデルを学習させる方法がいろいろあって混乱しますかね...

毎度、モヤモヤ感がいっぱいですな... 

今回はこのへんで。