当前位置:网站首页>[meta learning] classic work MAML and reply (Demo understands meta learning mechanism)
[meta learning] classic work MAML and reply (Demo understands meta learning mechanism)
2022-06-22 06:54:00 【chad_ lee】
Meta Learning
MAML ICML’17
MAML And model structure 、 Task independent , The only requirement is that the model has parameters .
MAML Generate an initialization of the weight , Other models can be based on a small number of samples fine-tuning. therefore MAML Input and function of and Pre-train It's the same .
Algorithm

MAML You can use this picture to make it clear , The left figure shows the algorithm flow ∣ T i ∣ = 1 |\mathcal{T}_{i}|=1 ∣Ti∣=1 The situation of .
First , The model has an initialization parameter θ \theta θ:

Take a tasks T i ∼ p ( T ) \mathcal{T}_{i} \sim p(\mathcal{T}) Ti∼p(T). In this task Of K K K Training data ( also called support set) Last training , Calculate the gradient ∇ θ L T i ( f θ ) \nabla_{\theta} \mathcal{L}_{\mathcal{T}_{i}}\left(f_{\theta}\right) ∇θLTi(fθ)【 The first 5 That's ok 】, Then update it with a gradient θ \theta θ( It can be many times ), obtain θ ′ \theta^{\prime} θ′.【 The first 6 That's ok 】:
If it's normal training , Then a batch of data will be sampled , And then to θ ′ \theta^{\prime} θ′ Continue training as a starting point ,MAML It is :

And then use θ ′ \theta^{\prime} θ′ stay task i Test data for ( also called query set) Last training , Calculate the gradient ∇ θ L T i ( f θ i ′ ) \nabla_{\theta} \mathcal{L}_{\mathcal{T}_{i}}\left(f_{\theta_{i}^{\prime}}\right) ∇θLTi(fθi′), to update θ \theta θ【 The first 8 That's ok 】:

Such a ( A group of )task It's done , Go on to the next ( Next batch )task.
The form is the same for classification or regression tasks , It's just that the loss function is different from how to deal with data :

experiment
Omniglot Data sets :1623 Letters , Each letter has 20 A picture .【 But this data set is relatively simple , The accuracy has 99+ 了 】
MiniImagenet Data sets : Training set 64 Classes , Verification set 12 Classes , Test set 24 Classes .【 current sota It's already MAML Twice as much 】
The Omniglot and MiniImagenet image recognition tasks are the most com- mon recently used few-shot learning benchmarks.
Training is “N-ways K-shot”, That is, in every training and test tasks in , Yes N individual class,K Samples :

Reptile:On First-Order Meta-Learning Algorithms Arxiv’18
OpenAI Articles produced ,follow And improve MAML, The number of citations has 700+
The core idea
Above, MAML My thoughts are rather convoluted , Initial parameters of the model θ 0 \theta^{0} θ0 First in the dataset A On the training to get θ ′ \theta^{\prime} θ′; Then sample a data set B, Calculation θ ′ \theta^{\prime} θ′ stay B The gradient above , Then on θ 0 \theta^{0} θ0 updated , obtain θ 1 \theta^1 θ1:
θ 1 = θ 0 − ε ∇ θ ∑ T ⋅ ∈ P L T i ( f θ ′ ) \theta^{1}=\theta^{0}-\varepsilon \nabla_{\theta} \sum_{\mathcal{T} \cdot \in P} \mathcal{L}_{\mathcal{T}_{i}}\left(f_{\theta^{\prime}}\right) θ1=θ0−ε∇θT⋅∈P∑LTi(fθ′)
MAML A good initial parameter is obtained by training θ \theta θ( Better than pre training ), The calculation of the second derivative will be involved in the calculation of the gradient ,MAML Using the first derivative approximation (FOMAML) To deal with , simplified calculation .
What this article puts forward Reptile stay FOMAML To further simplify the parameter update method , There is no need to calculate the second loss gradient , Direct use θ 0 − θ ′ \theta^{0}-\theta^{\prime} θ0−θ′ As a gradient , Update the parameters :
θ 1 = θ 0 − ε ( θ 0 − θ ′ ) \theta^{1}=\theta^{0}-\varepsilon\left(\theta^{0}-\theta^{\prime}\right) θ1=θ0−ε(θ0−θ′)
Pictured above , Initial parameter θ 0 \theta^0 θ0 In the data set A Do more batch The calculation of reached the parameter θ ′ \theta^{\prime} θ′, And then back to θ 0 \theta^0 θ0, Calculation θ 0 − θ ′ \theta^{0}-\theta^{\prime} θ0−θ′, And update to get θ 1 \theta^1 θ1. If it's normal training , Will not return to θ 0 \theta^0 θ0, Will θ ′ \theta^{\prime} θ′ Continue updating for starting point .
Specially , If there is only one data in each data set / One batch data , that Reptile Will degenerate into ordinary training .
Pre-train、MAML and Reptile The difference between :

Task Divide
OpenAI Of Reptile The blog of There is one of them. demo, The image shows Reptile The wonder of , It also helps to understand task The definition of

There is already a built-in Reptile Well trained few shot learning Three classification model , The user can give three training samples ( One for each of the three categories ), The model will be fine tuned on three samples , This is it. 3-way 1-shot. Then draw a test sample on the right , The model will give the probability distribution of three classes .
here “ Chi Chi camel Chi ” The four pictures are one 3-way 1-shot Model task.
ProtoNet、MAML、Reptile、MetaOptNet、R2-D2 Data set partitioning 、 The task division is basically the same , They also mentioned in the article , To ensure the comparative effect of the experiment ,follow The experimental setup of the previous article , No new task. Just some training trick, among ProtoNet For model performance “Higher way”、R2-D2 use random shot Training models .
边栏推荐
- 2022-06-21:golang选择题,以下golang代码输出什么?A:3;B:4;C:100;D:编译失败。 package main import ( “fmt“ ) func
- 实训渗透靶场02|3星vh-lll靶机|vulnhub靶场Node1
- Laravel excel 3.1 column width setting does not work
- 【5G NR】手机身份证号IMEI与IMEISV
- Introduction to 51 single chip microcomputer - matrix key
- 编程题:移除数组中的元素(JS实现)
- 仙人掌之歌——进军To C直播(2)
- [php] composer installation
- [openairinterface5g] ITTI messaging mechanism
- Cesium加载3D Tiles模型
猜你喜欢

6. 安装ssh连接工具(用于我们连接实验室的服务器)

JDBC查询结果集,结果集转化成表
![[openairinterface5g] RRC NR resolution (I)](/img/04/fec30b5c86f29d82bd7d0b13293494.jpg)
[openairinterface5g] RRC NR resolution (I)

深度解析Optimism被盗2000万个OP事件(含代码)

流程引擎解决复杂的业务问题

Introduction to 51 Single Chip Microcomputer -- the use of Keil uvision4

【5G NR】NGAP协议之NG Setup

C skill tree evaluation - customer first, making excellent products

【5G NR】手机身份证号IMEI与IMEISV

Languo technology helps the ecological prosperity of openharmony
随机推荐
[5g NR] RRC connection reconstruction analysis
[5g NR] UE registration management status
Don't throw away the electric kettle. It's easy to fix!
JDBC查询结果集,结果集转化成表
golang調用sdl2,播放pcm音頻,報錯signal arrived during external code execution。
[php]tp6 cli mode to create tp6 and multi application configurations and common problems
Linux link sqlserver, offline installation
Introduction to PMOD interface of kv260
Anaconda introduction, installation and use nanny level tutorial
Iframe framework, native JS routing
Why did I choose rust
Py's optbinning: introduction, installation and detailed introduction of optbinning
5G-GUTI详解
关于solidity的delegatecall的坑
Rebuild binary tree
CNN模型合集 | Resnet变种-WideResnet解读
Py's scorecardpy: a detailed introduction to the introduction, installation and use of scorecardpy
Correspondence between pytorch and torchvision
leetcode:面试题 08.12. 八皇后【dfs + backtrack】
SQL injection vulnerability (XII) cookie injection