Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
JP7646497B2 - Learning device and learning method - Google Patents
[go: Go Back, main page]

JP7646497B2 - Learning device and learning method - Google Patents

Learning device and learning method Download PDF

Info

Publication number
JP7646497B2
JP7646497B2 JP2021133806A JP2021133806A JP7646497B2 JP 7646497 B2 JP7646497 B2 JP 7646497B2 JP 2021133806 A JP2021133806 A JP 2021133806A JP 2021133806 A JP2021133806 A JP 2021133806A JP 7646497 B2 JP7646497 B2 JP 7646497B2
Authority
JP
Japan
Prior art keywords
loss
model
learning
inference
teacher
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
JP2021133806A
Other languages
Japanese (ja)
Other versions
JP2023028233A (en
Inventor
竜介 関
康貴 岡田
雄喜 片山
怜 広見
葵 荻島
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Denso Ten Ltd
Original Assignee
Denso Ten Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Denso Ten Ltd filed Critical Denso Ten Ltd
Priority to JP2021133806A priority Critical patent/JP7646497B2/en
Priority to US17/687,019 priority patent/US20230054706A1/en
Publication of JP2023028233A publication Critical patent/JP2023028233A/en
Application granted granted Critical
Publication of JP7646497B2 publication Critical patent/JP7646497B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Analysis (AREA)

Description

本発明は、学習装置および学習方法に関する。 The present invention relates to a learning device and a learning method.

従来、ディープラーニング(深層学習)の学習手法の一つとして、知識蒸留(Knowledge Distillation)と呼ばれる手法が知られている(例えば特許文献1参照)。知識蒸留においては、パラメータ数の多い大規模な教師モデルを用いて、パラメータ数の少ない生徒モデルの訓練が行われる。知識蒸留により、モデルのサイズを小さくしつつ、モデルの性能の低下を抑制することができる。 Conventionally, a method called knowledge distillation has been known as one of the learning methods for deep learning (see, for example, Patent Document 1). In knowledge distillation, a large-scale teacher model with a large number of parameters is used to train a student model with a small number of parameters. Knowledge distillation can reduce the size of the model while suppressing degradation of the model's performance.

国際公開第2020/161797号International Publication No. 2020/161797

知識蒸留を利用した学習手法において、教師モデルの推論誤差の大きさに関わらず一律に、教師モデルを用いた生徒モデルの訓練を行うと、教師モデルの推論誤差が大きい場合に、生徒モデルを誤って訓練する虞がある。すなわち、教師モデルの推論誤差を無視して生徒モデルの訓練を行うと、生徒モデルの性能を低下させる虞がある。 In a learning method that uses knowledge distillation, if a student model is trained using a teacher model uniformly regardless of the magnitude of the teacher model's inference error, there is a risk that the student model will be trained incorrectly if the teacher model has a large inference error. In other words, if the student model is trained while ignoring the inference error of the teacher model, there is a risk that the performance of the student model will be degraded.

本発明は、上記の点に鑑み、知識蒸留を利用した深層学習において、生徒モデルを適切に訓練することができる技術を提供することを目的とする。 In view of the above, the present invention aims to provide a technology that can appropriately train a student model in deep learning using knowledge distillation.

例示的な本発明の学習装置は、教師モデルを用いて生徒モデルを訓練する学習装置であって、前記教師モデルの推論結果の学習データに対する損失である第1損失を求める第1損失算出部と、前記生徒モデルの推論結果の学習データに対する損失である第2損失を求める第2損失算出部と、前記第1損失と前記第2損失とに基づいて前記教師モデルを用いた訓練とするか否かを判定する判定部と、を備える。 An exemplary learning device of the present invention is a learning device that trains a student model using a teacher model, and includes a first loss calculation unit that calculates a first loss, which is a loss for the learning data of the inference result of the teacher model, a second loss calculation unit that calculates a second loss, which is a loss for the learning data of the inference result of the student model, and a determination unit that determines whether or not to use the teacher model for training based on the first loss and the second loss.

例示的な本発明の学習方法は、教師モデルを用いて生徒モデルを訓練する学習方法であって、前記教師モデルの推論結果の学習データに対する損失である第1損失と、前記生徒モデルの推論結果の学習データに対する損失である第2損失とに基づいて、前記教師モデルを用いた訓練とするか否かを判定する。 An exemplary learning method of the present invention is a learning method for training a student model using a teacher model, and determines whether to use the teacher model for training based on a first loss, which is a loss of the inference result of the teacher model for the learning data, and a second loss, which is a loss of the inference result of the student model for the learning data.

例示的な本発明によれば、知識蒸留を利用した深層学習において、生徒モデルを適切に訓練することができる。 According to the exemplary present invention, in deep learning using knowledge distillation, a student model can be appropriately trained.

学習装置のハードウェア構成を示すブロック図Block diagram showing the hardware configuration of a learning device 学習装置が備えるプロセッサの機能構成を示すブロック図A block diagram showing the functional configuration of a processor included in the learning device. 学習装置における生徒モデルの訓練の流れを示すフローチャートA flow chart showing the flow of training a student model in a learning device.

以下、本発明の例示的な実施形態について、図面を参照しながら詳細に説明する。 An exemplary embodiment of the present invention will now be described in detail with reference to the drawings.

<1.学習装置>
図1は、本発明の実施形態に係る学習装置10のハードウェア構成を示すブロック図である。学習装置10は、機械学習用の学習装置であり、学習手法として知識蒸留を利用する。学習装置10は、教師モデルを用いて生徒モデルを訓練する学習装置である。学習装置10は、教師モデルを用いて生徒モデルを訓練する学習方法を実行する。詳細には、学習装置10は、学習データおよび教師モデルを用いて生徒モデルに学習させる。
1. Learning device
1 is a block diagram showing a hardware configuration of a learning device 10 according to an embodiment of the present invention. The learning device 10 is a learning device for machine learning, and uses knowledge distillation as a learning method. The learning device 10 is a learning device that trains a student model using a teacher model. The learning device 10 executes a learning method for training the student model using the teacher model. In detail, the learning device 10 causes the student model to learn using training data and the teacher model.

本実施形態においては、学習データは、学習装置10に入力される。また、学習データは、正解ラベル付きの学習データである。学習装置10は、教師モデル及び生徒モデルを有する。教師モデルは、パラメータ数の多い大規模なディープニューラルネットワークであり、既に学習済みのモデルである。生徒モデルは、教師モデルに比べてパラメータ数の少ない小規模のディープニューラルネットワークである。生徒モデルは、これから学習(訓練)を行わせるモデルである。 In this embodiment, the learning data is input to the learning device 10. The learning data is also learning data with a correct answer label. The learning device 10 has a teacher model and a student model. The teacher model is a large-scale deep neural network with a large number of parameters, and is a model that has already been trained. The student model is a small-scale deep neural network with a smaller number of parameters than the teacher model. The student model is a model that will be used for learning (training).

なお、本実施形態では、教師モデルおよび生徒モデルは、物体検出を行うモデルである。教師モデルは、生徒モデルよりも高性能である。例えば、教師モデルの物体検出率は、生徒モデルの物体検出率よりも高い。本実施形態によれば、物体検出処理を高速で行うことができる高性能の学習済みモデルを、知識蒸留を用いて生成することができる。 In this embodiment, the teacher model and the student model are models that perform object detection. The teacher model has higher performance than the student model. For example, the object detection rate of the teacher model is higher than that of the student model. According to this embodiment, a high-performance trained model that can perform object detection processing at high speed can be generated using knowledge distillation.

図1に示すように、学習装置10は、プロセッサ11と記憶部12とを備える。記憶部12は、教師モデルおよび生徒モデルを記憶する。教師モデルは、学習済みパラメータを含む。生徒モデルは、学習により更新されるパラメータを含む。プロセッサ11は、記憶部12に記憶されている教師モデルを用いた学習データに対する推論、および、生徒モデルを用いた学習データに対する推論を行う機能を発揮する。プロセッサ11は、教師モデルの推論結果と、生徒モデルの訓練結果との誤差が小さくなるように、生徒モデルのパラメータを更新する機能を発揮する。なお、推論結果の代わりに、中間層の特徴マップが利用されてもよい。 As shown in FIG. 1, the learning device 10 includes a processor 11 and a memory unit 12. The memory unit 12 stores a teacher model and a student model. The teacher model includes learned parameters. The student model includes parameters that are updated through learning. The processor 11 performs a function of performing inference on learning data using the teacher model stored in the memory unit 12, and inference on learning data using the student model. The processor 11 performs a function of updating the parameters of the student model so that the error between the inference result of the teacher model and the training result of the student model is reduced. Note that a feature map of the intermediate layer may be used instead of the inference result.

図2は、本発明の実施形態に係る学習装置10が備えるプロセッサ11の機能構成を示すブロック図である。プロセッサ11の機能は、記憶部12に記憶されるプログラムにしたがった演算処理の実行により発揮される。図2に示すように、本実施形態のプロセッサ11は、その機能として、抽出部110と、第1推論部111と、第2推論部112と、第1損失算出部113と、第2損失算出部114と、判定部115と、学習部116とを備える。換言すると、学習装置10は、抽出部110と、第1推論部111と、第2推論部112と、第1損失算出部113と、第2損失算出部114と、判定部115と、学習部116とを備える。抽出部110は、予め準備された複数の、正解ラベル付きの学習データから所定数の学習データを抽出してミニバッチを生成する。 FIG. 2 is a block diagram showing the functional configuration of the processor 11 included in the learning device 10 according to an embodiment of the present invention. The functions of the processor 11 are exerted by executing arithmetic processing according to a program stored in the storage unit 12. As shown in FIG. 2, the processor 11 of this embodiment includes, as its functions, an extraction unit 110, a first inference unit 111, a second inference unit 112, a first loss calculation unit 113, a second loss calculation unit 114, a judgment unit 115, and a learning unit 116. In other words, the learning device 10 includes the extraction unit 110, the first inference unit 111, the second inference unit 112, the first loss calculation unit 113, the second loss calculation unit 114, the judgment unit 115, and the learning unit 116. The extraction unit 110 extracts a predetermined number of learning data from a plurality of learning data with correct answer labels prepared in advance to generate a mini-batch.

第1推論部111は、学習済みの教師モデルを利用して、入力された学習データに対する推論を行う。第1推論部111の機能は、プロセッサ11によって記憶部12に記憶される教師モデルが読み込まれることにより実現される。推論により、推論の最終的な結果である推論結果や、中間出力である特徴マップ等が得られる。本実施形態では、学習データは画像データであり、第1推論部111は、入力された画像データに対する物体検出を行う。第1推論部111の推論結果には、物体の種類および位置の特定が含まれる。物体の種類は、例えば、歩行者、自転車、自動車、信号機等である。位置の特定には、バウンディングボックスが利用される。 The first inference unit 111 uses a trained teacher model to perform inference on the input training data. The function of the first inference unit 111 is realized by the processor 11 reading in a teacher model stored in the memory unit 12. Through inference, an inference result that is the final result of the inference and a feature map that is an intermediate output are obtained. In this embodiment, the training data is image data, and the first inference unit 111 performs object detection on the input image data. The inference result of the first inference unit 111 includes the identification of the type and position of the object. The type of object is, for example, a pedestrian, a bicycle, a car, a traffic light, etc. A bounding box is used to identify the position.

第2推論部112は、教師モデルによる訓練の対象である生徒モデルを利用して、入力された学習データに対する推論を行う。第2推論部112の機能は、プロセッサ11によって記憶部12に記憶されている生徒モデルが読み込まれることにより実現される。推論により、推論の最終的な結果である推論結果や、中間出力である特徴マップ等が得られる。なお、生徒モデルのパラメータは、学習により逐次更新される。本実施形態では、上述のように学習データは画像データであり、第2推論部112は、入力された画像データに対する物体検出を行う。第2推論部112の推論結果には、第1推論部111と同様に、物体の種類と位置の特定とが含まれる。 The second inference unit 112 performs inference on the input learning data using a student model that is the subject of training by the teacher model. The function of the second inference unit 112 is realized by the processor 11 reading the student model stored in the memory unit 12. Through inference, an inference result that is the final result of inference and a feature map that is an intermediate output are obtained. The parameters of the student model are successively updated through learning. In this embodiment, as described above, the learning data is image data, and the second inference unit 112 performs object detection on the input image data. As with the first inference unit 111, the inference result of the second inference unit 112 includes identification of the type and position of the object.

第1損失算出部113は、教師モデルの推論結果の学習データに対する損失である第1損失Loss_1を求める。第1損失Loss_1は、教師モデルの推論結果と、学習データの正解ラベルとの誤差(以下、推論誤差と表現することがある)である。本実施形態では、学習タスクは物体検出であり、第1損失Loss_1には、例えば、クラス分類損失とバウンディングボックス回帰損失とが含まれる。第1損失Loss_1は、例えば、以下の式(1)により求めることができる。すなわち、第1損失Loss_1は、式(1)の第1項から第5項の和により求めることができる。 The first loss calculation unit 113 calculates a first loss Loss_1, which is a loss of the inference result of the teacher model for the training data. The first loss Loss_1 is an error between the inference result of the teacher model and the correct label of the training data (hereinafter, may be expressed as an inference error). In this embodiment, the learning task is object detection, and the first loss Loss_1 includes, for example, a classification loss and a bounding box regression loss. The first loss Loss_1 can be calculated, for example, by the following formula (1). That is, the first loss Loss_1 can be calculated by the sum of the first to fifth terms of formula (1).

なお、以下の式(1)は、物体検出アルゴリズムの一例であるYOLOを利用する場合を想定したものである。YOLOでは、入力画像をS×Sのグリッドに区切り、グリッド毎に、ある一定のアスペクト比を持つB個の矩形領域の中心座標(x、y)、幅と高さのスケール(w、h)、および、矩形領域内に物体が存在する確率(C)を予測する。さらに、各矩形領域に何らかの物体が存在するとき、その物体がどのクラスに属するかを示す事後確率p(c)も予測する。YOLOでは、矩形領域、物体の存在確率、クラスの事後確率の予測を、1つの損失関数に統合している。 Note that the following formula (1) assumes the use of YOLO, an example of an object detection algorithm. YOLO divides the input image into an S x S grid, and for each grid, predicts the center coordinates (x, y), width and height scales (w, h), and probability (C) of an object present in B rectangular regions with a certain aspect ratio. Furthermore, when an object is present in each rectangular region, it also predicts the posterior probability p(c) indicating which class the object belongs to. YOLO combines predictions of rectangular regions, object presence probability, and class posterior probability into a single loss function.

Figure 0007646497000001
添え字がない変数は予測値、添え字「truth」が付与された変数が正解を示す。λcoord、λnoobjは係数である。式(1)において、第1項および第2項は、矩形領域の中心座標と大きさに関する損失関数を示す。式(1)において、第3項および第4項は、存在確率に関する損失関数を示す。式(1)において、第5項はクラスの事後確率に関する損失関数を示す。
Figure 0007646497000001
Variables without subscripts indicate predicted values, and variables with the subscript "truth" indicate correct answers. λcoord and λnoobj are coefficients. In equation (1), the first and second terms indicate loss functions related to the center coordinates and size of the rectangular region. In equation (1), the third and fourth terms indicate loss functions related to the existence probability. In equation (1), the fifth term indicates a loss function related to the posterior probability of the class.

第2損失算出部114は、生徒モデルの推論結果の学習データに対する損失である第2損失Loss_2を求める。第2損失Loss_2は、生徒モデルの推論結果と、学習データの正解ラベルとの誤差(推論誤差)である。本実施形態では、学習タスクは物体検出であり、第2損失Loss_2には、例えば、クラス分類損失とバウンディングボックス回帰損失とが含まれる。第2損失Loss_2は、例えば、第1損失Loss_1と同様に式(1)を用いて求めることができる。すなわち、第2損失Loss_2は、式(1)の第1項から第5項の和により求めることができる。 The second loss calculation unit 114 calculates the second loss Loss_2, which is the loss of the inference result of the student model for the training data. The second loss Loss_2 is the error (inference error) between the inference result of the student model and the correct label of the training data. In this embodiment, the learning task is object detection, and the second loss Loss_2 includes, for example, a classification loss and a bounding box regression loss. The second loss Loss_2 can be calculated, for example, using equation (1) in the same way as the first loss Loss_1. That is, the second loss Loss_2 can be calculated by the sum of the first to fifth terms of equation (1).

判定部115は、第1損失Loss_1と第2損失Loss_2とに基づいて教師モデルを用いた訓練とするか否かを判定する。すなわち、本実施形態の学習方法によれば、教師モデルの推論結果の学習データに対する第1損失Loss_1と、生徒モデルの推論結果の学習データに対する第2損失Loss_2とに基づいて、教師モデルを用いた訓練とするか否かが判定される。このような構成とすれば、例えば教師モデルの推論誤差が生徒モデルの推論誤差よりも大きい場合等に、教師モデルを用いた生徒モデルの訓練を行わない構成にできる。すなわち、教師モデルの誤った知識を生徒モデルに蒸留することを抑制することができる。 The determination unit 115 determines whether or not to perform training using a teacher model based on the first loss Loss_1 and the second loss Loss_2. That is, according to the learning method of this embodiment, it is determined whether or not to perform training using a teacher model based on the first loss Loss_1 for the learning data of the inference result of the teacher model and the second loss Loss_2 for the learning data of the inference result of the student model. With this configuration, it is possible to configure the student model not to be trained using the teacher model when, for example, the inference error of the teacher model is larger than the inference error of the student model. That is, it is possible to suppress the distillation of erroneous knowledge of the teacher model into the student model.

詳細には、判定部115は、第1損失Loss_1が第2損失Loss_2よりも小さい場合に、教師モデルを用いた訓練とすると判定する。これによれば、生徒モデルよりも優れた教師モデルの知識を適切に生徒モデルに蒸留することができ、生徒モデルの性能(物体検出率等)を適切に向上させることができる。 In detail, when the first loss Loss_1 is smaller than the second loss Loss_2, the determination unit 115 determines that training should be performed using the teacher model. This allows knowledge of the teacher model, which is superior to the student model, to be appropriately distilled into the student model, and the performance (object detection rate, etc.) of the student model can be appropriately improved.

また、判定部115は、第1損失Loss_1が第2損失Loss_2以上である場合には、教師モデルを用いた訓練としないと判定する。これにより、生徒モデルに教師モデルの誤った知識の蒸留を行うことを抑制することができる。 In addition, if the first loss Loss_1 is equal to or greater than the second loss Loss_2, the determination unit 115 determines not to use the teacher model for training. This makes it possible to prevent erroneous knowledge of the teacher model from being distilled into the student model.

学習部116は、損失関数を用いて生徒モデルを学習する。学習部116は、損失関数により算出した損失が最小化するように生徒モデルを学習する。詳細には、学習部116は、誤差逆伝播法を用いて生徒モデルのパラメータの更新を行う。本実施形態では、学習部116は、判定部115の判定結果に応じて生徒モデルの学習の仕方を異ならせる。 The learning unit 116 learns the student model using the loss function. The learning unit 116 learns the student model so as to minimize the loss calculated by the loss function. In detail, the learning unit 116 updates the parameters of the student model using the backpropagation method. In this embodiment, the learning unit 116 changes the way the student model is learned depending on the judgment result of the judgment unit 115.

学習部116は、教師モデルを用いた訓練とすると判定された場合に、第2損失Loss_2と、教師モデルに対する損失(蒸留損失)Ldstlとを用いて生徒モデルの損失Loss_sを求める。学習部116は、求めた生徒モデルの損失Loss_sに基づき生徒モデルの学習を行う。このような構成とすると、生徒モデルより優れた性能を有する教師モデルと、学習データとの両方を用いて生徒モデルを学習することができ、生徒モデルを高性能の学習モデルとすることができる。 When it is determined that training should be performed using the teacher model, the learning unit 116 calculates the loss Loss_s of the student model using the second loss Loss_2 and the loss (distillation loss) Ldstl for the teacher model. The learning unit 116 learns the student model based on the calculated loss Loss_s of the student model. With this configuration, the student model can be learned using both the teacher model, which has better performance than the student model, and the learning data, and the student model can be a high-performance learning model.

なお、蒸留損失Ldstlは、教師モデルと生徒モデルとの間の、推論結果の誤差、或いは、中間層の特徴マップ(中間出力)の誤差である。本実施形態では、蒸留損失Ldstlは、教師モデルの特徴マップと、生徒モデルの特徴マップとの間の誤差である。蒸留損失Ldstlは、例えば、以下の式(2)で表されるL2損失であってよい。ただし、蒸留損失Ldstlは、L2損失以外であってもよく、例えば、教師モデルと生徒モデルの出力の分布間の損失を表すKLダイバージェンス等であってもよい。 The distillation loss Ldstl is the error of the inference result between the teacher model and the student model, or the error of the feature map of the intermediate layer (intermediate output). In this embodiment, the distillation loss Ldstl is the error between the feature map of the teacher model and the feature map of the student model. The distillation loss Ldstl may be, for example, the L2 loss represented by the following formula (2). However, the distillation loss Ldstl may be something other than the L2 loss, and may be, for example, the KL divergence that represents the loss between the distribution of the outputs of the teacher model and the student model.

Figure 0007646497000002
式(2)において、nはサンプル(データ)の数を示す。fxi は、サンプルxiの生徒モデルの出力を示す。fxi は、サンプルxiの教師モデルの出力を示す。
Figure 0007646497000002
In formula (2), n indicates the number of samples (data), f xi s indicates the output of the student model for sample xi, and f xi t indicates the output of the teacher model for sample xi.

また、学習部116は、教師モデルを用いた訓練としないと判定された場合に、生徒モデルの損失Loss_sを第2損失Loss_2として生徒モデルの学習を行う。この場合、学習データのみを用いて生徒モデルを学習することになるが、誤った知識を蒸留する可能性がある教師モデルを除外して学習を行うことができるので、生徒モデルの性能が低下することを抑制できる。 When it is determined that training should not be performed using the teacher model, the learning unit 116 learns the student model with the loss Loss_s of the student model set as the second loss Loss_2. In this case, the student model is learned using only the learning data, but since learning can be performed by excluding the teacher model that may distill erroneous knowledge, it is possible to suppress a decrease in the performance of the student model.

<2.学習方法>
図3は、本発明の実施形態に係る学習装置10における生徒モデルの訓練の流れを示すフローチャートである。なお、図3に示すフローチャートの開始前に、公知の手法により学習が行われた学習済みの教師モデルが作成されている。
2. Learning Methods
3 is a flowchart showing a flow of training a student model in the learning device 10 according to an embodiment of the present invention. Note that, before the start of the flowchart shown in FIG. 3, a trained teacher model that has been trained by a known method is created.

ステップS1において、抽出部110は、予め準備された複数の正解ラベル付きの学習データから所定数のデータをサンプリング(抽出)してミニバッチを生成する。学習データは、例えば、複数の画像データを含む。学習データに含まれる複数の画像データのそれぞれは、正解ラベルを有する。所定数は、適宜決められる任意の数である。例えば、予め準備された学習データ(画像データ)の総数が10000枚であるとした場合、所定数は100枚等とされる。ステップS1の処理が完了すると、次のステップS2に処理が進められる。なお、ミニバッチは、学習装置10とは別の装置で生成されてよい。すなわち、ミニバッチを構成するデータが学習装置10に適宜入力される構成としてもよい。このような構成の場合には、学習装置10は抽出部110を備えなくてよい。 In step S1, the extraction unit 110 samples (extracts) a predetermined number of data from a plurality of previously prepared learning data with correct answer labels to generate a mini-batch. The learning data includes, for example, a plurality of image data. Each of the plurality of image data included in the learning data has a correct answer label. The predetermined number is an arbitrary number that is appropriately determined. For example, if the total number of previously prepared learning data (image data) is 10,000, the predetermined number is set to 100, etc. When the processing of step S1 is completed, the processing proceeds to the next step S2. Note that the mini-batch may be generated by a device other than the learning device 10. In other words, the data constituting the mini-batch may be configured to be input to the learning device 10 as appropriate. In such a configuration, the learning device 10 does not need to include the extraction unit 110.

ステップS2では、第1推論部111による推論が行われる。詳細には、記憶部12から学習済みモデルである教師モデルのパラメータがプロセッサ11に読み込まれて、ミニバッチに対して教師モデルを用いた推論が行われる。当該推論により、ミニバッチを構成する各学習データに対して、推論の最終的な結果である推論結果が得られる。ステップS2の処理が完了すると、次のステップS3に処理が進められる。 In step S2, inference is performed by the first inference unit 111. In detail, parameters of a teacher model, which is a trained model, are read from the memory unit 12 into the processor 11, and inference is performed on the mini-batch using the teacher model. Through this inference, an inference result, which is the final result of inference, is obtained for each piece of training data that constitutes the mini-batch. When the processing of step S2 is completed, the processing proceeds to the next step S3.

ステップS3では、第1損失算出部113が、ミニバッチを構成する各学習データについて、ステップS2で得られた推論結果と正解ラベルとを用いて第1損失Loss_1を算出する。第1損失Loss_1は、教師モデルの推論誤差である。第1損失Loss_1は、上述の式(1)により求めることができる。ステップS3の処理が完了すると、次のステップS4に処理が進められる。 In step S3, the first loss calculation unit 113 calculates the first loss Loss_1 for each learning data constituting the mini-batch using the inference result and the correct label obtained in step S2. The first loss Loss_1 is the inference error of the teacher model. The first loss Loss_1 can be calculated by the above-mentioned formula (1). When the processing of step S3 is completed, the processing proceeds to the next step S4.

ステップS4では、第2推論部112による推論が行われる。詳細には、記憶部12から学習対象である生徒モデルのパラメータがプロセッサ11に読み込まれて、ミニバッチに対して生徒モデルを用いた推論が行われる。当該推論により、ミニバッチを構成する各学習データに対して、推論の最終的な結果である推論結果が得られる。ステップS4の処理が完了すると、次のステップS5に処理が進められる。 In step S4, inference is performed by the second inference unit 112. In detail, parameters of the student model to be learned are read from the memory unit 12 into the processor 11, and inference is performed on the mini-batch using the student model. This inference results in an inference result that is the final result of inference for each piece of learning data that constitutes the mini-batch. When the processing of step S4 is completed, the processing proceeds to the next step S5.

ステップS5では、第2損失算出部114が、ミニバッチを構成する各学習データについて、ステップS4で得られた推論結果と正解ラベルとを用いて第2損失Loss_2を算出する。第2損失Loss_2は生徒モデルの推論誤差である。第2損失Loss_2は、上述の式(1)により求めることができる。ステップS5の処理が完了すると、次のステップS6に処理が進められる。 In step S5, the second loss calculation unit 114 calculates the second loss Loss_2 for each learning data constituting the mini-batch using the inference result and the correct label obtained in step S4. The second loss Loss_2 is the inference error of the student model. The second loss Loss_2 can be calculated using the above-mentioned formula (1). When the processing of step S5 is completed, the processing proceeds to the next step S6.

なお、本実施形態では、教師モデルを用いた推論および損失の算出が、生徒モデルを用いた推論および損失の算出よりも先に行われる構成としているが、これは例示にすぎない。例えば、生徒モデルを用いた推論および損失の算出が、教師モデルを用いた推論および損失の算出よりも先に行われる構成としてもよい。 In this embodiment, the inference and loss calculation using the teacher model is performed before the inference and loss calculation using the student model, but this is merely an example. For example, the inference and loss calculation using the student model may be performed before the inference and loss calculation using the teacher model.

ステップS6では、判定部115によって、第1損失Loss_1が第2損失Loss_2よりも小さいか否かが確認される。第1損失Loss_1が第2損失Loss_2よりも小さい場合(ステップS6でYes)、次のステップS7に処理が進められる。一方、第1損失Loss_1が第2損失Loss_2以上である場合(ステップS6でNo)、ステップS11に処理が進められる。 In step S6, the determination unit 115 checks whether the first loss Loss_1 is smaller than the second loss Loss_2. If the first loss Loss_1 is smaller than the second loss Loss_2 (Yes in step S6), the process proceeds to the next step S7. On the other hand, if the first loss Loss_1 is equal to or greater than the second loss Loss_2 (No in step S6), the process proceeds to step S11.

ステップS7では、蒸留損失Ldstlが算出される。蒸留損失Ldstlは、上述の式(2)により求めることができる。教師モデルの推論誤差が生徒モデルの推論誤差よりも小さく、教師モデルの推論が信頼できるために、教師モデルを用いた知識の蒸留を行うために、蒸留損失Ldstlが算出される。ステップS7の処理が完了すると、次のステップS8に処理が進められる。 In step S7, the distillation loss Ldstl is calculated. The distillation loss Ldstl can be calculated using the above formula (2). Since the inference error of the teacher model is smaller than the inference error of the student model and the inference of the teacher model is reliable, the distillation loss Ldstl is calculated to perform knowledge distillation using the teacher model. When the processing of step S7 is completed, the processing proceeds to the next step S8.

ステップS8では、生徒モデルの損失Loss_sが、第2損失Loss_2と蒸留損失Ldstlとを用いて得られる損失とされる。なお、生徒モデルの損失Loss_sは、詳細には、以下の式(3)で表される構成であってよい。
Loss_s = Loss_2 + λ・Ldstl (3)
λは、第2損失Loss_2と蒸留損失Ldstlとのバランスを調整する重み係数である。重み係数λは、任意に決定される定数である。ステップS8の処理が完了すると、次のステップS9に処理が進められる。
In step S8, the loss Loss_s of the student model is set to a loss obtained by using the second loss Loss_2 and the distillation loss Ldstl. In addition, the loss Loss_s of the student model may be expressed in detail by the following formula (3).
Loss_s = Loss_2 + λ・Ldstl (3)
λ is a weighting coefficient for adjusting the balance between the second loss Loss_2 and the distillation loss Ldstl. The weighting coefficient λ is a constant that is determined arbitrarily. When the process of step S8 is completed, the process proceeds to the next step S9.

ステップS9では、学習部116が生徒モデルの損失Loss_sが最小化するように生徒モデルを学習する。詳細には、学習部116は、誤差逆伝播法を用いて生徒モデルのパラメータを更新する。ステップS9の処理が完了すると、次のステップS10に処理が進められる。 In step S9, the learning unit 116 learns the student model so as to minimize the loss Loss_s of the student model. In detail, the learning unit 116 updates the parameters of the student model using the backpropagation method. When the processing of step S9 is completed, the processing proceeds to the next step S10.

ステップS10では、所定の学習回数(Iteration)が実行されたか否かを確認する。所定の学習回数は、学習データの数等に応じて予め設定される。所定の学習回数が完了した場合(ステップS10でYes)、図3に示す生徒モデルの訓練(学習)が完了する。これにより、生徒モデルの学習を完了して学習済みモデルの完成としてもよいが、図3に示す学習処理を所定の回数(epoch数)繰り返して学習を完了する(学習済みモデルを完成する)構成としてもよい。 In step S10, it is confirmed whether a predetermined number of learning iterations has been performed. The predetermined number of learning iterations is set in advance according to the number of learning data, etc. When the predetermined number of learning iterations has been completed (Yes in step S10), the training (learning) of the student model shown in FIG. 3 is completed. This may complete the learning of the student model and complete the trained model, but the learning process shown in FIG. 3 may also be repeated a predetermined number of times (epoch number) to complete the learning (complete the trained model).

ステップS11では、、生徒モデルの損失Loss_sが、第2損失Loss_2とされる。これは、教師モデルの推論誤差が生徒モデルの推論誤差以上であり、教師モデルの推論が信頼できないために、教師モデルを用いた知識の蒸留を行わない趣旨である。生徒モデルは、正解ラベル付きの学習データのみを用いて学習される。すなわち、教師モデルを用いた訓練が行われない。ステップS11の処理が完了すると、上述のステップS9に処理が進められる。これにより、第2損失Loss_2(=Loss_s)が最小化するように、誤差逆伝播法を用いて生徒モデルの学習が行われる。 In step S11, the loss Loss_s of the student model is set to the second loss Loss_2. This is because the inference error of the teacher model is equal to or greater than the inference error of the student model, and the inference of the teacher model is unreliable, so knowledge distillation using the teacher model is not performed. The student model is trained using only training data with correct answer labels. In other words, training using the teacher model is not performed. When the processing of step S11 is completed, the processing proceeds to the above-mentioned step S9. As a result, the student model is trained using the backpropagation method so as to minimize the second loss Loss_2 (= Loss_s).

図3に示す学習手法によれば、教師モデルの推論が信頼できる場合に限って教師モデルの知識を生徒モデルに蒸留する構成であるために、教師モデルの知識を生徒モデルに適切に蒸留することができ、生徒モデルの性能の向上を図ることができる。図3に示す学習手法を用いた学習済みの生徒モデルは、教師モデルに比べてパラメータの数が少なく、高性能の処理を迅速に行うことができる。 According to the learning method shown in FIG. 3, the knowledge of the teacher model is distilled into the student model only when the inference of the teacher model is reliable, so that the knowledge of the teacher model can be appropriately distilled into the student model, and the performance of the student model can be improved. A student model that has been trained using the learning method shown in FIG. 3 has a smaller number of parameters than the teacher model, and can perform high-performance processing quickly.

<3.留意事項等>
本明細書中に開示されている種々の技術的特徴は、上記実施形態のほか、その技術的創作の主旨を逸脱しない範囲で種々の変更を加えることが可能である。すなわち、上記実施形態は、全ての点で例示であって、制限的なものではないと考えられるべきであり、本発明の技術的範囲は、上記実施形態の説明ではなく、特許請求の範囲によって示されるものであり、特許請求の範囲と均等の意味及び範囲内に属する全ての変更が含まれると理解されるべきである。また、本明細書中に示される複数の実施形態及び変形例は可能な範囲で適宜組み合わせて実施されてよい。
<3. Important points to note>
In addition to the above embodiment, various technical features disclosed in this specification can be modified in various ways without departing from the spirit of the technical creation. In other words, the above embodiment should be considered to be illustrative in all respects and not restrictive, and the technical scope of the present invention is indicated by the claims, not the description of the above embodiment, and should be understood to include all modifications that fall within the meaning and scope of the claims. In addition, the multiple embodiments and modifications shown in this specification may be implemented in appropriate combinations to the extent possible.

10・・・学習装置
113・・・第1損失算出部
114・・・第2損失算出部
115・・・判定部
116・・・学習部
10: Learning device 113: First loss calculation unit 114: Second loss calculation unit 115: Determination unit 116: Learning unit

Claims (6)

教師モデルを用いて生徒モデルを訓練する学習装置であって、プロセッサを備え、
前記プロセッサは、
前記教師モデルの推論結果の学習データに対する損失である第1損失を求め
前記生徒モデルの推論結果の学習データに対する損失である第2損失を求め
前記第1損失と前記第2損失とに基づいて前記教師モデルを用いた訓練とするか否かを判定し、
前記第1損失が前記第2損失よりも小さい場合に、前記教師モデルを用いた訓練とする、学習装置。
A learning device for training a student model using a teacher model, comprising: a processor;
The processor,
A first loss is calculated , which is a loss of the inference result of the teacher model with respect to the learning data;
A second loss is calculated , which is a loss of the inference result of the student model with respect to the learning data;
determining whether to perform training using the teacher model based on the first loss and the second loss;
A learning device that performs training using the teacher model if the first loss is smaller than the second loss .
前記プロセッサは、前記教師モデルを用いた訓練とすると判定された場合に、前記第2損失と、前記教師モデルに対する損失とを用いて前記生徒モデルの損失を求め、求めた前記損失に基づき前記生徒モデルの学習を行う、請求項に記載の学習装置。 2. The learning device according to claim 1, wherein when it is determined that training should be performed using the teacher model, the processor calculates a loss for the student model using the second loss and a loss for the teacher model , and learns the student model based on the calculated loss . 前記プロセッサは、前記教師モデルを用いた訓練としないと判定された場合に、前記生徒モデルの損失を前記第2損失として前記生徒モデルの学習を行う、請求項に記載の学習装置。 The learning device according to claim 2 , wherein when it is determined that training should not be performed using the teacher model, the processor learns the student model by using a loss of the student model as the second loss. 前記教師モデルおよび前記生徒モデルは、物体検出を行うモデルである、請求項1からのいずれか1項に記載の学習装置。 The learning device according to claim 1 , wherein the teacher model and the student model are models that perform object detection. 教師モデルを用いて生徒モデルを訓練する学習方法であって、
前記教師モデルの推論結果の学習データに対する損失である第1損失と、前記生徒モデルの推論結果の学習データに対する損失である第2損失とに基づいて、前記教師モデルを用いた訓練とするか否かを判定し、
前記第1損失が前記第2損失よりも小さい場合に、前記教師モデルを用いた訓練とする、学習方法。
A learning method for training a student model using a teacher model, comprising:
determining whether to perform training using the teacher model based on a first loss, which is a loss of the inference result of the teacher model for the learning data, and a second loss, which is a loss of the inference result of the student model for the learning data ;
A learning method, comprising: training using the teacher model if the first loss is smaller than the second loss .
教師モデルを用いて生徒モデルを訓練する学習方法をコンピュータに実行させるプログラムであって、A program for causing a computer to execute a learning method for training a student model using a teacher model,
前記コンピュータを、The computer,
前記教師モデルの推論結果の学習データに対する損失である第1損失を求めることと、calculating a first loss which is a loss of the inference result of the teacher model with respect to the training data;
前記生徒モデルの推論結果の学習データに対する損失である第2損失を求めることと、Obtaining a second loss, which is a loss of the inference result of the student model for the training data;
前記第1損失と前記第2損失とに基づいて前記教師モデルを用いた訓練とするか否かを判定することと、determining whether to perform training using the teacher model based on the first loss and the second loss;
前記第1損失が前記第2損失よりも小さい場合に、前記教師モデルを用いた訓練とすることと、When the first loss is smaller than the second loss, training is performed using the teacher model; and
を実行する手段として機能させる、プログラム。A program that serves as a means to execute a program.
JP2021133806A 2021-08-19 2021-08-19 Learning device and learning method Active JP7646497B2 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
JP2021133806A JP7646497B2 (en) 2021-08-19 2021-08-19 Learning device and learning method
US17/687,019 US20230054706A1 (en) 2021-08-19 2022-03-04 Learning apparatus and learning method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2021133806A JP7646497B2 (en) 2021-08-19 2021-08-19 Learning device and learning method

Publications (2)

Publication Number Publication Date
JP2023028233A JP2023028233A (en) 2023-03-03
JP7646497B2 true JP7646497B2 (en) 2025-03-17

Family

ID=85331654

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2021133806A Active JP7646497B2 (en) 2021-08-19 2021-08-19 Learning device and learning method

Country Status (1)

Country Link
JP (1) JP7646497B2 (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112183718A (en) 2020-08-31 2021-01-05 华为技术有限公司 Deep learning training method and device for computing equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112183718A (en) 2020-08-31 2021-01-05 华为技术有限公司 Deep learning training method and device for computing equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Seyed Iman Mirzadeh et al.,Improved Knowledge Distillation via Teacher Assistant,arXiv [online],2019年12月17日,pp.1-11,https://arxiv.org/abs/1902.03393

Also Published As

Publication number Publication date
JP2023028233A (en) 2023-03-03

Similar Documents

Publication Publication Date Title
Henderson et al. End-to-end training of object class detectors for mean average precision
WO2021155706A1 (en) Method and device for training business prediction model by using unbalanced positive and negative samples
CN113569852B (en) Semantic segmentation model training method, device, electronic device and storage medium
CN114386604B (en) Model distillation method, device, equipment and storage medium based on multi-teacher model
KR102011788B1 (en) Visual Question Answering Apparatus Using Hierarchical Visual Feature and Method Thereof
CN110362814B (en) Named entity identification method and device based on improved loss function
CN111325318A (en) Neural network training method, neural network training device and electronic equipment
CN112200889A (en) Sample image generation, image processing, intelligent driving control method and device
CN111368634B (en) Human head detection method, system and storage medium based on neural network
WO2016095068A1 (en) Pedestrian detection apparatus and method
JP7697317B2 (en) Expertise-based identification and quantification of confounding bias
CN111709415A (en) Object detection method, apparatus, computer equipment and storage medium
US20230054706A1 (en) Learning apparatus and learning method
US20250265472A1 (en) Diffusion-reward adversarial imitation learning
CN118152897B (en) Sensitive information identification model training method, device, equipment and storage medium
US12190570B2 (en) Object detection device, learning method, and recording medium
JP7507172B2 (en) Information processing method, information processing system, and information processing device
CN116091905B (en) A domain-adaptive impact crater detection method, system, device, and storage medium
JP7310927B2 (en) Object tracking device, object tracking method and recording medium
JP7646497B2 (en) Learning device and learning method
JP7651406B2 (en) Learning device and learning method
CN116150038B (en) Neuron sensitivity-based white-box test sample generation method
CN118840610A (en) Robust noise tag learning method based on double-flow sample distillation and related device
CN119399610A (en) Power image quality assessment method and system based on adaptive super network architecture
CN112132269A (en) Model processing method, device, equipment and storage medium

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20240626

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20241217

A521 Request for written amendment filed

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20250131

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20250225

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20250305

R150 Certificate of patent or registration of utility model

Ref document number: 7646497

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150