JP2022180119A - Data analysis system - Google Patents
Data analysis system Download PDFInfo
- Publication number
- JP2022180119A JP2022180119A JP2021087045A JP2021087045A JP2022180119A JP 2022180119 A JP2022180119 A JP 2022180119A JP 2021087045 A JP2021087045 A JP 2021087045A JP 2021087045 A JP2021087045 A JP 2021087045A JP 2022180119 A JP2022180119 A JP 2022180119A
- Authority
- JP
- Japan
- Prior art keywords
- feature vector
- loss function
- value
- arcface
- machine learning
- 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.)
- Pending
Links
Images
Landscapes
- Image Analysis (AREA)
Abstract
Description
本発明は、データ解析システムに関する。 The present invention relates to data analysis systems.
特許文献1には、ニューラルネットワークにより構成された識別器を用いて、外観画像における欠陥の有無を検査する外観検査装置が記載されている。一般に、外観画像における欠陥の有無の検査などのように、クラス分類を行う機械学習モデルは、クラス分類の境界が明確であることが望まれる。
クラス分類を行うためのニューラルネットワークからなる機械学習モデルの学習方法は、種々知られている。例えば、ユークリッド距離、マンハッタン距離、チェビシェフ距離などのように、特徴量空間における距離を用いて学習を行う方法がある。この場合、例えば、Center Lossなどの距離学習用の損失関数を用いる。 Various methods of learning a machine learning model consisting of a neural network for performing class classification are known. For example, there is a method of learning using distances in feature space, such as Euclidean distance, Manhattan distance, and Chebyshev distance. In this case, for example, a loss function for distance learning such as Center Loss is used.
また、角度を用いた距離学習として、ArcFace、CosFace、SphereFaceなどが知られている。これらの距離学習は、特徴ベクトルと正解クラスの重みベクトルとの内積に対して、正解クラスの場合にマージンを付加して、学習を行う手法である。これらの距離学習は、特徴ベクトルと正解クラスの重みベクトルとのなす角θを小さくするように学習する手法である。そして、これらの距離学習の手法は、マージンの与え方がそれぞれ異なる。また、一般に、予測精度は、ArcFaceが最も良く、次にCosFace、その次にSphereFaceの順となる。 ArcFace, CosFace, SphereFace, etc. are known as distance learning using angles. These distance learning methods are methods of learning by adding a margin in the case of the correct class to the inner product of the feature vector and the weight vector of the correct class. These distance learning methods are methods of learning so as to reduce the angle θ between the feature vector and the weight vector of the correct class. These distance learning methods differ in how to give a margin. Also, in general, ArcFace has the best prediction accuracy, followed by CosFace, and then SphereFace.
発明者は、角度を用いた距離学習として、ArcFaceによるマージン付加処理を適用して勾配法を用いて学習する場合、初期における、特徴ベクトルと重みベクトルとのなす角θにおけるcos距離(cos類似度とも称する)が小さい場合に、学習が進まない場合があることを発見した。 The inventors found that, as distance learning using angles, when margin addition processing by ArcFace is applied and learning is performed using the gradient method, the initial cos distance (cos similarity ) is small, learning may not progress.
本発明は、かかる課題に鑑みてなされたものであり、ArcFaceによる高い予測精度を利用しつつ、ArcFaceにより学習が進まない問題を解決し、高精度な予測を可能とする機械学習モデルを生成することができるデータ解析システムを提供しようとするものである。 The present invention has been made in view of this problem, and solves the problem that learning does not progress with ArcFace while utilizing the high prediction accuracy of ArcFace, and generates a machine learning model that enables highly accurate prediction. It is intended to provide a data analysis system capable of
本発明の一態様は、
演算処理装置および記憶装置を備えるコンピュータ装置により構成されたデータ解析システムであって、
前記記憶装置は、ニューラルネットワークより構成され、最終段の全結合層の重みベクトルを用いて特徴ベクトルを出力し、対象のデータに関する前記特徴ベクトルとクラス代表のデータに関する前記特徴ベクトルとのcos距離によりクラス分類を行うための機械学習モデルを記憶し、
前記演算処理装置は、
学習用データを入力した場合に前記機械学習モデルを実行することにより前記特徴ベクトルを出力する機械学習モデル実行部と、
前記機械学習モデル実行部が前記特徴ベクトルを出力した際の前記重みベクトルを取得する重みベクトル取得部と、
前記特徴ベクトルと正解クラスの前記重みベクトルとのなす角θが所定値より小さい場合に、前記特徴ベクトルおよび前記重みベクトルを用いてArcFaceによるマージン付加処理を適用して損失関数の値を算出し、前記なす角θが前記所定値以上の場合に、前記特徴ベクトルおよび前記重みベクトルを用いてCosFaceによるマージン付加処理を適用して損失関数の値を算出する損失関数演算部と、
前記損失関数の値に基づいて勾配法により前記機械学習モデルの学習を行う学習処理部と、
を備える、データ解析システムにある。
One aspect of the present invention is
A data analysis system configured by a computer device comprising an arithmetic processing device and a storage device,
The storage device is composed of a neural network, and outputs a feature vector using the weight vector of the fully connected layer at the final stage. store a machine learning model for classifying,
The arithmetic processing unit is
a machine learning model execution unit that outputs the feature vector by executing the machine learning model when learning data is input;
a weight vector acquisition unit that acquires the weight vector when the machine learning model execution unit outputs the feature vector;
when the angle θ between the feature vector and the weight vector of the correct class is smaller than a predetermined value, applying margin addition processing by ArcFace using the feature vector and the weight vector to calculate the value of the loss function; a loss function calculation unit that calculates a loss function value by applying margin addition processing by CosFace using the feature vector and the weight vector when the formed angle θ is equal to or greater than the predetermined value;
a learning processing unit that learns the machine learning model by a gradient method based on the value of the loss function;
in a data analysis system comprising
機械学習モデルの学習は、角度を用いた距離学習としてのArcFaceとCosFaceを併用している。具体的には、損失関数演算部が、特徴ベクトルと重みベクトルとのなす角θが所定値より小さい場合には、ArcFaceによるマージン付加処理を適用し、なす角θが所定値以上の場合には、CosFaceによるマージン付加処理を適用している。 The learning of the machine learning model uses both ArcFace and CosFace as distance learning using angles. Specifically, when the angle θ formed by the feature vector and the weight vector is smaller than a predetermined value, the loss function calculation unit applies margin addition processing by ArcFace, and when the angle θ formed is greater than or equal to a predetermined value, , Margin addition processing by CosFace is applied.
従って、ArcFaceによるマージン付加処理のみの場合に学習が進まない可能性のある領域は、CosFaceによるマージン付加処理が適用されている。従って、全体として、ArcFaceにて学習が進まなくなるような領域は存在せず、CosFaceにより確実に学習が進む状態とすることができる。 Therefore, margin addition processing by CosFace is applied to areas where there is a possibility that learning will not progress if only margin addition processing by ArcFace is performed. Therefore, as a whole, there is no region where learning is not progressed with ArcFace, and a state can be established in which learning is reliably progressed with CosFace.
さらに、学習が進むと、特徴ベクトルと正解クラスの重みベクトルとのなす角θは小さくなる。学習の初期において、特徴ベクトルと正解クラスの重みベクトルとのなす角θが所定値より大きい場合において、CosFaceによるマージン付加処理が適用される。その後、学習が進むことで、なす角θが小さくなる。そうすると、なす角θが所定値に到達し、CosFaceの領域から、ArcFaceの領域へ移行する。その後、ArcFaceによる学習が進むことにより、高精度な予測を行うことができる機械学習モデルが生成される。 Furthermore, as the learning progresses, the angle θ between the feature vector and the weight vector of the correct class becomes smaller. At the beginning of learning, when the angle θ between the feature vector and the weight vector of the correct class is greater than a predetermined value, CosFace margin addition processing is applied. After that, as the learning progresses, the formed angle θ becomes smaller. Then, the formed angle θ reaches a predetermined value, and the area of CosFace shifts to the area of ArcFace. After that, as learning by ArcFace progresses, a machine learning model capable of making highly accurate predictions is generated.
(1.機械学習モデル)
機械学習モデルは、ニューラルネットワークにより構成される。ここでのニューラルネットワークは、隠れ層が1層である場合、または、隠れ層が複数層である場合を含み意味で用いている。つまり、隠れ層が複数層ある場合には、いわゆるディープニューラルネットワークと称する。もちろん、機械学習モデルは、ニューラルネットワークとして、例えば、畳み込みニューラルネットワークなどを適用することができる。機械学習モデルは、ニューラルネットワークにより構成されるため、入力されるデータに対応する特徴ベクトルを出力する。
(1. Machine learning model)
A machine learning model is composed of a neural network. The term "neural network" as used herein includes the case where the number of hidden layers is one or the case where the number of hidden layers is multiple. In other words, when there are multiple hidden layers, it is called a so-called deep neural network. Of course, the machine learning model can apply, for example, a convolutional neural network as a neural network. Since the machine learning model is composed of a neural network, it outputs a feature vector corresponding to input data.
本形態の機械学習モデルは、各ニューロンにおいて、重み、バイアス、活性化関数などを用いた処理を行う。主に、重みおよびバイアスが学習対象となる。そして、機械学習モデルは、最終段の全結合層の出力が特徴ベクトルとなる。最終段の全結合層は、重みベクトルを用いて特徴ベクトルを出力する。 The machine learning model of this embodiment performs processing using weights, biases, activation functions, etc. in each neuron. Weights and biases are mainly learned. In the machine learning model, the output of the fully connected layer at the final stage becomes the feature vector. The fully connected layer at the final stage outputs the feature vector using the weight vector.
本形態においては、機械学習モデルは、対象のデータのクラス分類を行うためのモデルである。例えば、対象のデータに関する特徴ベクトルが、各クラスの代表データに関する特徴ベクトルに近いか否かを判定することにより、対象のデータがどのクラスに属するかを判定することができる。本形態においては、機械学習モデルは、対象のデータに関する特徴ベクトルとクラス代表のデータに関する特徴ベクトルとcos距離により、対象のデータのクラス分類を行うためのモデルである。 In this embodiment, the machine learning model is a model for classifying target data. For example, it is possible to determine to which class the target data belongs by determining whether or not the feature vector relating to the target data is close to the feature vector relating to the representative data of each class. In this embodiment, the machine learning model is a model for performing class classification of target data based on feature vectors relating to target data, feature vectors relating to class representative data, and cos distances.
例えば、機械学習モデルは、画像データを対象として、画像データのクラス分類に用いるモデルとすることができる。この場合、機械学習モデルは、対象の画像データに関する特徴ベクトルとクラス代表の画像データに関する特徴ベクトルとのcos距離により、対象の画像データのクラス分類を行う。 For example, the machine learning model can be a model that targets image data and is used for classifying image data. In this case, the machine learning model performs class classification of the target image data based on the cos distance between the feature vector relating to the target image data and the feature vector relating to the class representative image data.
特に、機械学習モデルは、産業製品の外観検査に用いるモデルを例にあげる。この場合、産業製品の外観の画像データを入力して、対象の産業製品が良品であるか不良品であるかの判定を行う。具体的には、機械学習モデルに対象の外観画像データを入力した場合に出力される特徴ベクトルを取得する。また、機械学習モデルに良品の代表画像データを入力した場合に出力される特徴ベクトルを取得する。さらに、機械学習モデルに不良品の代表画像データを入力した場合に出力される特徴ベクトルを取得する。 In particular, the machine learning model is exemplified by a model used for visual inspection of industrial products. In this case, by inputting image data of the appearance of the industrial product, it is determined whether the target industrial product is a non-defective product or a defective product. Specifically, a feature vector that is output when external image data of a target is input to the machine learning model is acquired. Also, a feature vector that is output when the representative image data of a non-defective product is input to the machine learning model is acquired. Furthermore, the feature vector output when the representative image data of the defective product is input to the machine learning model is acquired.
そして、対象の外観画像データに関する特徴ベクトルと良品の代表画像データに関する特徴ベクトルとのcos距離より、対象の外観画像データが良品のクラスに分類されるかを判定する。一方、対象の外観画像データに関する特徴ベクトルと不良品の代表画像データに関する特徴ベクトルとのcos距離より、対象の外観画像データが不良品のクラスに分類されるかを判定する。このように、各クラスの代表の画像データに関する特徴ベクトルとのcos距離に基づいて、産業製品が、良品であるか不良品であるかの判定を行うことができる。 Then, based on the cos distance between the feature vector related to the target appearance image data and the feature vector related to the non-defective representative image data, it is determined whether the target appearance image data is classified into the non-defective product class. On the other hand, it is determined whether the target appearance image data is classified into the defective product class from the cos distance between the feature vector relating to the target appearance image data and the feature vector relating to the representative image data of the defective product. In this way, it is possible to determine whether an industrial product is good or bad based on the cos distance between the feature vector and the representative image data of each class.
不良品の種類が複数存在する場合には、対象の外観画像データに関する特徴ベクトルと、それぞれの不良品の代表画像データに関する特徴ベクトルとのcos距離により、対象の外観画像データがどの不良品のクラスに分類されるかを判定することもできる。ここで、産業製品としては、車両部品、産業機械部品、民生機器部品など種々の部品を対象とできる。 If there are multiple types of defective products, the cos distance between the feature vector related to the target external image data and the feature vector related to the representative image data of each defective product determines which class of defective product the target external image data belongs to. It is also possible to determine whether it is classified into Here, as industrial products, various parts such as vehicle parts, industrial machine parts, and consumer equipment parts can be targeted.
(2.データ解析システム1の学習フェーズの概要)
データ解析システム1の学習フェーズにおける構成の概要について、図1を参照して説明する。データ解析システム1は、記憶装置2および演算処理装置3を備えるコンピュータ装置により構成される。
(2. Outline of learning phase of data analysis system 1)
An overview of the configuration of the
記憶装置2は、上述した機械学習モデル11を記憶する。さらに、記憶装置2は、機械学習モデルの学習フェーズにおいて用いる学習用データ12を記憶する。学習用データ12は、例えば、産業製品の外観画像データであって、良品の画像データおよび不良品の画像データを含む。さらに、学習用データ12は、各画像データが良品であるか不良品であるかの情報、すなわち正解ラベル12aを含む。
The
記憶装置2は、さらに、損失関数演算用プログラム13を記憶する。損失関数演算用プログラムは、ArcFaceによるマージン付加処理を適用して損失関数の値を算出するプログラム、および、CosFaceによるマージン付加処理を適用して損失関数の値を算出するプログラムを含む。
The
演算処理装置3は、機械学習モデル実行部21、特徴ベクトル正規化処理部22、重みベクトル取得部23、重みベクトル正規化処理部24、損失関数演算部25、および、学習処理部26を備える。
The
機械学習モデル実行部21は、機械学習モデル11に画像データを入力した場合に、入力された画像データに関する特徴ベクトルを出力する。学習フェーズにおいて、機械学習モデル実行部21は、記憶装置2に記憶されている外観画像の学習用データ12を入力して、入力された学習用データ12に関する特徴ベクトルを出力する。特徴ベクトル正規化処理部22は、機械学習モデル実行部21により出力された特徴ベクトルに対してL2正規化を行う。
When image data is input to the
重みベクトル取得部23は、機械学習モデル実行部21が特徴ベクトルを出力した際の最終段の全結合層の重みベクトルを取得する。重みベクトル正規化処理部24は、重みベクトル取得部23が取得した重みベクトルに対してL2正規化を行う。
The weight
損失関数演算部25は、記憶装置2に記憶されている損失関数演算用プログラム13を実行することにより、ArcFaceによるマージン付加処理を適用して損失関数の値Lossを算出する。さらに、損失関数演算部25は、損失関数演算用プログラム13を実行することにより、CosFaceによるマージン付加処理を適用して損失関数の値Lossを算出する。2つのマージン付加処理の適用の概要は、次のとおりである。
The loss
損失関数演算部25は、特徴ベクトルと正解クラスの重みベクトルとのなす角θが所定値より小さい場合に、特徴ベクトルおよび重みベクトルを用いてArcFaceによるマージン付加処理を適用して損失関数の値Lossを算出する。一方、損失関数演算部25は、なす角θが所定値以上の場合に、特徴ベクトルおよび重みベクトルを用いてCosFaceによるマージン付加処理を適用して損失関数の値Lossを算出する。損失関数の値Lossの算出においては、記憶装置20に記憶されている学習用データ12に含まれる正解ラベル12aを用いる。
When the angle θ between the feature vector and the weight vector of the correct class is smaller than a predetermined value, the loss
学習処理部26は、損失関数演算部25により算出された損失関数の値Lossに基づいて、勾配法により機械学習モデル11の学習を行う。学習処理部26は、記憶装置2に記憶されている機械学習モデル11の重みおよびバイアスを学習する。本形態においては、学習処理部26は、損失関数の値Lossが最小値または極小値となるように、勾配降下法を適用して学習する。
The
(3.データ解析システム1の学習フェーズの詳細構成)
データ解析システム1の学習フェーズの詳細な構成について図2を参照して説明する。機械学習モデル実行部21が、学習用データ12に含まれる画像データを入力し、機械学習モデルを実行する。そうすると、機械学習モデル実行部21が、特徴ベクトルを出力する。ここで、入力される学習用データ12に含まれる画像データをxとして、出力される特徴ベクトルをx’とした場合、式(1)のように表される。f()は、機械学習モデル11を表す関数である。
(3. Detailed configuration of learning phase of data analysis system 1)
A detailed configuration of the learning phase of the
特徴ベクトル正規化処理部22が、特徴ベクトルx’をL2正規化することで、正規化後特徴ベクトルx”を出力する。特徴ベクトルx’と正規化後特徴ベクトルx”とは、式(2)のように表される。正規化後特徴ベクトルx”は、特徴ベクトルx’の長さを1としたベクトルである。
The feature vector
重みベクトル取得部23が、機械学習モデル実行部21が実行した機械学習モデル11における最終段の全結合層の重みベクトルWを取得する。重みベクトル正規化処理部24が、重みベクトルWをL2正規化することで、正規化後重みベクトルW’を出力する。重みベクトルWと正規化後重みベクトルW’とは、式(3)のように表される。正規化後重みベクトルW’は、重みベクトルWの長さを1としたベクトルである。
The weight
損失関数演算部25は、ArcFace適用部30と、CosFace適用部40とを備える。ArcFace適用部30は、内積算出部31、ArcFace演算部32、ロジット算出部33、ソフトマックス関数演算部34、損失算出部35を備える。CosFace適用部40は、内積算出部41、CosFace演算部42、ロジット算出部43、ソフトマックス関数演算部44、損失算出部45を備える。ただし、ArcFace適用部30の内積算出部31と、CosFace適用部40の内積算出部41とは、同一の処理を行うため、共通したプログラムを実行するようにしても良い。
The
ArcFace適用部30の内積算出部31は、正規化後特徴ベクトルx”と正規化後重みベクトルW’とを取得する。そして、内積算出部31は、式(4)に示すように、正規化後特徴ベクトルx”と正規化後重みベクトルW’との内積であるcos距離(cosθ)を算出する。CosFace適用部40の内積算出部41も同様である。
The inner
ArcFace演算部32は、式(5)に従って、正規化後特徴ベクトルx”と正解クラスjの正規化後重みベクトルW’とのなす角θが所定値θThより小さい場合に、正規化後特徴ベクトルx”と正規化後重みベクトルW’とのなす角θを用いて、ArcFaceにより角度θ’を算出する。ArcFace演算部32は、正解クラスjに対応する場合には、ArcFaceによるマージンmaを付加する処理(マージン付加処理)を実行する。ArcFace演算部32は、正解クラスjに対応しない場合には、マージンmaを付加せずに、正規化後特徴ベクトルx”と正規化後重みベクトルW’とのなす角θを用いる。
If the angle θ between the normalized feature vector x″ and the normalized weight vector W′ of the correct class j is smaller than a predetermined value θTh, the
ここで、所定値θThは、式(6)により表される。 Here, the predetermined value θ Th is represented by Equation (6).
ArcFace演算部32は、前述のなす角θが所定値θThより小さい場合に、式(5)により算出した角θ’jを用いて、式(7)に表されるように、cos距離(cosθ’j)を算出する。つまり、ArcFace演算部32は、正解クラスjに対応する場合には、マージンmaが付加されたときのcos距離(cosθ’j)を算出する。一方、ArcFace演算部32は、正解クラスjに対応しない場合には、マージンmaを付加せずに、内積算出部31により算出されたcos距離(cosθ’j)をそのまま用いる。
When the formed angle θ is smaller than the predetermined value θTh , the
CosFace演算部42は、式(8)に従って、正規化後特徴ベクトルx”と正解クラスjの正規化後重みベクトルW’とのなす角θが所定値θTh以上の場合に、CosFaceによる処理を行う。CosFace演算部42は、正解クラスjに対応する場合には、CosFaceによるマージンmcを付加する処理(マージン付加処理)を実行して、マージンmcが付加されたときのcos距離(cosθ’j)を算出する。一方、CosFace演算部42は、正解クラスjに対応しない場合には、マージンmcを付加せずに、内積算出部31により算出されたcos距離(cosθ’j)をそのまま用いる。
The
ここで、CosFaceによるマージンmcは、式(9)により表される。 Here, the margin mc by CosFace is represented by Equation (9).
ArcFace適用部30のロジット算出部33は、式(10)に従って、ArcFace演算部32により算出されたcos距離(cosθ’j)に、スケールパラメータsを乗算することにより、ロジットlogitを算出する。また、CosFace適用部40のロジット算出部43も、同様の処理を行う。すなわち、ロジット算出部43は、式(10)に従って、CosFace演算部42により算出されたcos距離(cosθ’j)に、スケールパラメータsを乗算することにより、ロジットlogitを算出する。
The
ArcFace適用部30のソフトマックス関数演算部34は、式(11)に従って、ロジット算出部33により算出されたロジットlogitをソフトマックス関数により変換する。同様に、CosFace適用部40のソフトマックス関数演算部44は、式(11)に従って、ロジット算出部43により算出されたロジットlogitをソフトマックス関数により変換する。
The softmax
ArcFace適用部30の損失算出部35は、式(12)に従って、ArcFaceによる損失関数の値Lossarcを算出する。損失算出部35は、ロジット算出部33により算出されたロジットlogitに対して損失関数としてのクロスエントロピーを適用することにより、損失関数の値Lossarcとしてクロスエントロピー誤差を算出する。クロスエントロピー誤差の算出においては、学習用データ12における正解ラベル12aを用いる。
The
つまり、式(12)に示すArcFaceによる損失関数は、マージンmaを付加することにより、正解クラスjの重みベクトルWyiと特徴ベクトルx’iとのcos距離を実際より小さく見積もり、不正解クラスの重みベクトルWと特徴ベクトルx’とのcos距離を実際より大きく見積もっていることに相当する。つまり、他のクラスの重みベクトルWよりも、正解クラスjの重みベクトルWyiにより近づくように損失関数の値Lossarcを与えているため、正解クラスの重みベクトルと不正解クラスの重みベクトルとを引き離す効果を有する。 That is, the loss function by ArcFace shown in Equation (12) estimates the cos distance between the weight vector Wyi of the correct answer class j and the feature vector x'i smaller than the actual value by adding the margin ma , and the incorrect answer class This corresponds to overestimating the cos distance between the weight vector W and the feature vector x'. That is, since the loss function value Loss arc is given so as to be closer to the weight vector Wyi of the correct class j than the weight vector W of other classes, the weight vector of the correct class and the weight vector of the incorrect class are divided into It has a pulling effect.
CosFace適用部40の損失算出部45は、式(13)に従って、CosFaceによる損失関数の値Losscosを算出する。損失算出部45は、ロジット算出部43により算出されたロジットlogitに対して損失関数としてのクロスエントロピーを適用することにより、損失関数の値Losscosとしてクロスエントロピー誤差を算出する。クロスエントロピー誤差の算出においては、学習用データ12における正解ラベル12aを用いる。
The
つまり、式(13)に示すCosFaceによる損失関数は、マージンmcを付加することにより、ArcFaceと基本的には同様に機能する。つまり、CosFaceによる損失関数は、正解クラスjの重みベクトルWyiと特徴ベクトルx’iとのcos距離を実際より小さく見積もり、不正解クラスの重みベクトルWと特徴ベクトルx’とのcos距離を実際より大きく見積もっていることに相当する。つまり、他のクラスの重みベクトルWよりも、正解クラスjの重みベクトルWyiにより近づくように損失関数の値Losscosを与えているため、正解クラスの重みベクトルと不正解クラスの重みベクトルとを引き離す効果を有する。 That is, the loss function by CosFace shown in Equation (13) functions basically in the same way as ArcFace by adding a margin mc . In other words, the loss function by CosFace underestimates the cos distance between the weight vector Wyi of the correct class j and the feature vector x'i , and the cos distance between the weight vector W of the incorrect class j and the feature vector x'. It is equivalent to making a larger estimate. That is, since the loss function value Loss cos is given so as to be closer to the weight vector Wyi of the correct class j than the weight vector W of other classes, the weight vector of the correct class and the weight vector of the incorrect class are divided into It has a pulling effect.
学習処理部26は、正規化後特徴ベクトルx”と正解クラスjの正規化後重みベクトルW’とのなす角θが所定値θTh以上の場合には、ArcFace適用部30の損失算出部35により算出された損失関数の値Lossarc(式(12)に示す)を用いて、勾配法により機械学習モデル11を学習する。
When the angle θ between the normalized feature vector x″ and the normalized weight vector W′ of the correct class j is equal to or greater than a predetermined value θTh , the
また、学習処理部26は、正規化後特徴ベクトルx”と正解クラスjの正規化後重みベクトルW’とのなす角θが所定値θThより小さい場合には、CosFace適用部40の損失算出部45により算出された損失関数の値Losscos(式(13)に示す)を用いて、勾配法により機械学習モデル11を学習する。
Further, when the angle θ between the normalized feature vector x″ and the normalized weight vector W′ of the correct class j is smaller than a predetermined value θ Th , the
(4.第一のマージン適用時のcos距離と損失関数の値)
第一のマージン適用時における「正規化後特徴ベクトルx”と正解クラスの重みベクトルW’とのcos距離」と「損失関数の値Loss」との関係について、図3を参照して説明する。ここで、図3には、機械学習モデル11の学習においてArcFaceとCosFaceの併用パターンとしての本形態を実線にて示しており、比較例としてArcFaceのみを適用したパターンについて破線にて示している。
(4. Values of cos distance and loss function when applying the first margin)
The relationship between the "cos distance between the normalized feature vector x" and the weight vector W' of the correct class and the "loss function value Loss" when the first margin is applied will be described with reference to FIG. Here, in FIG. 3, the solid line indicates this embodiment as a combined pattern of ArcFace and CosFace in the learning of the
比較例としてのArcFaceのみを適用した場合には、cos距離に対する損失関数の値が、cos距離が小さい領域のうちのcosθEのときに極値(本形態では極大値)を持つ。学習の初期において、cos距離がcosθEよりも大きな値の場合には、勾配法を適用して学習すると、cos距離がより大きい方に移動して行く。そのため、cos距離を大きくする方向に学習が進んで行き、理想的な状態に近づいて行く。一方、学習の初期において、cos距離がcosθEよりも小さな値の場合には、勾配法を適用して学習すると、cos距離がより小さい方に移動して行く。そのため、cos距離を大きくする方向に学習が進まない。 When only ArcFace as a comparative example is applied, the value of the loss function with respect to the cos distance has an extreme value (maximum value in this embodiment) at cos θ E in the small cos distance region. When the cos distance is larger than cos θ E in the initial stage of learning, learning by applying the gradient method causes the cos distance to move to a larger value. Therefore, learning progresses in the direction of increasing the cos distance, and the ideal state is approached. On the other hand, when the cos distance is smaller than cos θ E in the initial stage of learning, learning by applying the gradient method moves the cos distance to a smaller value. Therefore, learning does not progress in the direction of increasing the cos distance.
ArcFaceによるマージン付加処理は、式(7)に示すように、なす角θに角度のマージンmaを加算する処理である。そのため、なす角θが大きい場合(180°付近の場合)、θ+maの角度が180°を超える場合には、変換後のcos距離の値の変化が、大小逆転する場合がある。このことを理由に、ArcFaceによるマージン付加処理は、上記のような関係を有することになる。 The margin adding process by ArcFace is a process of adding an angle margin ma to the formed angle θ as shown in equation (7). Therefore, when the formed angle θ is large (in the vicinity of 180°), and when the angle θ+ ma exceeds 180°, the change in the value of the cos distance after conversion may be reversed in magnitude. For this reason, margin addition processing by ArcFace has the above relationship.
本形態を適用した場合には、図3に示すように、CosFaceを適用した領域と、ArcFaceを適用した領域とが存在する。ここで、CosFaceによるマージン付加処理は、式(8)に示すように、cosθからマージンmcを減算する処理である。従って、変換後のcos距離の値の変化は、cosθの変化と同一となり、ArcFaceの場合のように大小逆転することはない。 When this embodiment is applied, as shown in FIG. 3, there are areas to which CosFace is applied and areas to which ArcFace is applied. Here, the margin adding process by CosFace is the process of subtracting the margin mc from cos θ as shown in equation (8). Therefore, the change in the value of the cos distance after conversion is the same as the change in cos θ, and unlike the case of ArcFace, the magnitude is not reversed.
そして、ArcFaceを適用した領域とCosFaceを適用した領域との境界が、なす角θが所定値θThに対応するcos距離の値cosθThとなる。ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理は、なす角θが所定値θThの前後において、損失関数の値Lossが、cos距離に対して単調減少または単調増加する関係を有するように設定されている。本形態においては、cos距離が大きくなる場合に、損失関数の値Lossが単調減少するような関係を有するように設定されている。 Then, the angle θ formed by the boundary between the area to which ArcFace is applied and the area to which CosFace is applied becomes the cos distance value cos θTh corresponding to the predetermined value θTh . The margin addition processing by ArcFace and the margin addition processing by CosFace are set so that the value Loss of the loss function monotonically decreases or increases with respect to the cos distance when the formed angle θ reaches a predetermined value θTh . ing. In this embodiment, the loss function value Loss is set to monotonically decrease as the cos distance increases.
特に、所定値θThに対応するcos距離の値cosθThが、ArcFaceによるマージン付加処理においてcos距離に対する損失関数の値Lossarcが極値となるときのcos距離の値cosθEよりも大きな値となるように、所定値θThが設定されている。 In particular, the cos distance value cos θ Th corresponding to the predetermined value θ Th is greater than the cos distance value cos θ E when the loss function value Loss arc with respect to the cos distance becomes the extreme value in the margin addition processing by ArcFace. The predetermined value θ Th is set so that
つまり、本形態においては、ArcFaceのみを適用した場合のような極値を有しない。従って、学習の初期において、cos距離がどの位置に位置したとしても、勾配法を適用して学習することでcos距離がより大きい方に移動して行く。そのため、cos距離を大きくする方向に学習が進んで行き、理想的な状態に近づいて行く。 In other words, in this embodiment, there is no extreme value unlike when only ArcFace is applied. Therefore, no matter where the cos distance is located at the initial stage of learning, learning by applying the gradient method moves to the direction where the cos distance is larger. Therefore, learning progresses in the direction of increasing the cos distance, and the ideal state is approached.
さらに、ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理は、なす角θが所定値θThにおいて、損失関数の値Lossがcos距離に対して連続する関係を有するように設定されている。この場合、学習において、連続的に処理が進む。従って、学習が安定する。特に、なす角θが所定値θThにおいて、損失関数の値Lossがcos距離に対して滑らかに連続する関係を有するように設定されているとより良い。つまり、なす角θが所定値θThにおいて、損失関数の値Lossをcos距離による偏微分した値が、一致する状態となる。 Furthermore, margin addition processing by ArcFace and margin addition processing by CosFace are set so that the value Loss of the loss function has a continuous relationship with the cos distance when the formed angle θ is a predetermined value θTh . In this case, learning progresses continuously. Therefore, learning is stabilized. In particular, it is preferable that the angle .theta. is set to a predetermined value .theta.Th so that the value Loss of the loss function has a smooth continuous relationship with the cos distance. That is, when the formed angle θ is a predetermined value θ Th , the values obtained by partially differentiating the value Loss of the loss function with respect to the cos distance match.
ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理が、上記のように設定するためには、例えば、所定値θThの設定、および、CosFaceによるマージンmcの設定にて対応できる。 In order to set the margin addition processing by ArcFace and the margin addition processing by CosFace as described above, for example, the setting of the predetermined value θTh and the setting of the margin mc by CosFace can be done.
(5.第二のマージン適用時のcos距離と損失関数の値)
第二のマージン適用時における正規化後特徴ベクトルx”と正解クラスの重みベクトルW’とのcos距離と損失関数の値Lossとの関係について、図4を参照して説明する。ここで、図4には、図3と同様に、機械学習モデル11の学習においてArcFaceとCosFaceの併用パターンとしての本形態を実線にて示しており、比較例としてArcFaceのみを適用したパターンについて破線にて示している。
(5. Values of cos distance and loss function when applying the second margin)
The relationship between the cos distance between the normalized feature vector x″ and the weight vector W′ of the correct class and the loss function value Loss when the second margin is applied will be described with reference to FIG. 4, similar to FIG. 3, this embodiment as a pattern of combined use of ArcFace and CosFace in the learning of the
図4に示す第二のマージン適用時には、図3と比較して、ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理が、なす角θが所定値θThにおいて、損失関数の値Lossがcos距離に対して不連続の関係を有するように設定されている。ただし、ArcFaceを適用した領域とCosFaceを適用した領域との境界が、なす角θが所定値θThに対応するcos距離の値cosθThとなる。ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理は、なす角θが所定値θThの前後において、損失関数の値Lossが、cos距離に対して単調減少または単調増加する関係を有するように設定されている。 When the second margin shown in FIG. 4 is applied, compared with FIG. It is set to have a discontinuous relationship with respect to However, the angle θ formed by the boundary between the area to which ArcFace is applied and the area to which CosFace is applied is the cos distance value cos θTh corresponding to the predetermined value θTh . The margin addition processing by ArcFace and the margin addition processing by CosFace are set so that the value Loss of the loss function monotonically decreases or increases with respect to the cos distance when the formed angle θ reaches a predetermined value θTh . ing.
この場合も、本形態においては、ArcFaceのみを適用した場合のような極値を有しない。従って、学習の初期において、cos距離がどの位置に位置したとしても、勾配法を適用して学習することでcos距離がより大きい方に移動して行く。そのため、cos距離を大きくする方向に学習が進んで行き、理想的な状態に近づいて行く。 Again, in this embodiment, there are no extrema as in the case of applying only ArcFace. Therefore, no matter where the cos distance is located at the initial stage of learning, learning by applying the gradient method moves to the direction where the cos distance is larger. Therefore, learning progresses in the direction of increasing the cos distance, and the ideal state is approached.
そして、ArcFaceによるマージン付加処理およびCosFaceによるマージン付加処理が、上記のように設定するためには、例えば、所定値θThの設定、および、CosFaceによるマージンmcの設定にて対応できる。 In order to set the margin addition processing by ArcFace and the margin addition processing by CosFace as described above, for example, the setting of the predetermined value θTh and the setting of the margin mc by CosFace can correspond.
(6.効果)
以上のように、機械学習モデル11の学習は、角度を用いた距離学習としてのArcFaceとCosFaceを併用している。具体的には、損失関数演算部25は、特徴ベクトルx’と重みベクトルWとのなす角θが所定値θThより小さい場合には、式(5)(7)(12)に示すように、ArcFaceによるマージン付加処理を適用する。一方、損失関数演算部25は、なす角θが所定値θTh以上の場合には、式(8)(13)に示すように、CosFaceによるマージン付加処理を適用している。
(6. Effect)
As described above, the learning of the
従って、ArcFaceによるマージン付加処理のみの場合に学習が進まない可能性のある領域は、CosFaceによるマージン付加処理が適用されている。従って、全体として、ArcFaceにて学習が進まなくなるような領域は存在せず、CosFaceにより確実に学習が進む状態とすることができる。 Therefore, margin addition processing by CosFace is applied to areas where there is a possibility that learning will not progress if only margin addition processing by ArcFace is performed. Therefore, as a whole, there is no region where learning is not progressed with ArcFace, and a state can be established in which learning is reliably progressed with CosFace.
さらに、学習が進むと、特徴ベクトルx’と正解クラスの重みベクトルWとのなす角θは小さくなる。学習の初期において、特徴ベクトルx’と正解クラスの重みベクトルWとのなす角θが所定値θThより大きい場合(cos距離がcosθThより小さい場合)において、CosFaceによるマージン付加処理が適用される。その後、学習が進むことで、なす角θが小さくなる。そうすると、なす角θが所定値θThに到達し、CosFaceの領域から、ArcFaceの領域へ移行する。その後、ArcFaceによる学習が進むことにより、高精度な予測を行うことができる機械学習モデル11が生成される。
Furthermore, as the learning progresses, the angle θ between the feature vector x' and the weight vector W of the correct class becomes smaller. In the initial stage of learning, when the angle θ formed by the feature vector x′ and the weight vector W of the correct class is greater than a predetermined value θTh (when the cos distance is smaller than cosθTh ), margin addition processing by CosFace is applied. . After that, as the learning progresses, the formed angle θ becomes smaller. Then, the formed angle θ reaches a predetermined value θTh , and the region of CosFace shifts to the region of ArcFace. After that, as learning by ArcFace progresses, a
1 データ解析システム
2 記憶装置
3 演算処理装置
21 機械学習モデル実行部
23 重みベクトル取得部
25 損失関数演算部
26 学習処理部
REFERENCE SIGNS
Claims (8)
前記記憶装置は、ニューラルネットワークより構成され、最終段の全結合層の重みベクトルを用いて特徴ベクトルを出力し、対象のデータに関する前記特徴ベクトルとクラス代表のデータに関する前記特徴ベクトルとのcos距離によりクラス分類を行うための機械学習モデルを記憶し、
前記演算処理装置は、
学習用データを入力した場合に前記機械学習モデルを実行することにより前記特徴ベクトルを出力する機械学習モデル実行部と、
前記機械学習モデル実行部が前記特徴ベクトルを出力した際の前記重みベクトルを取得する重みベクトル取得部と、
前記特徴ベクトルと正解クラスの前記重みベクトルとのなす角θが所定値より小さい場合に、前記特徴ベクトルおよび前記重みベクトルを用いてArcFaceによるマージン付加処理を適用して損失関数の値を算出し、前記なす角θが前記所定値以上の場合に、前記特徴ベクトルおよび前記重みベクトルを用いてCosFaceによるマージン付加処理を適用して損失関数の値を算出する損失関数演算部と、
前記損失関数の値に基づいて勾配法により前記機械学習モデルの学習を行う学習処理部と、
を備える、データ解析システム。 A data analysis system configured by a computer device comprising an arithmetic processing device and a storage device,
The storage device is composed of a neural network, and outputs a feature vector using the weight vector of the fully connected layer at the final stage. store a machine learning model for classifying,
The arithmetic processing unit is
a machine learning model execution unit that outputs the feature vector by executing the machine learning model when learning data is input;
a weight vector acquisition unit that acquires the weight vector when the machine learning model execution unit outputs the feature vector;
when the angle θ between the feature vector and the weight vector of the correct class is smaller than a predetermined value, applying margin addition processing by ArcFace using the feature vector and the weight vector to calculate the value of the loss function; a loss function calculation unit that calculates a loss function value by applying margin addition processing by CosFace using the feature vector and the weight vector when the formed angle θ is equal to or greater than the predetermined value;
a learning processing unit that learns the machine learning model by a gradient method based on the value of the loss function;
A data analysis system comprising:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2021087045A JP2022180119A (en) | 2021-05-24 | 2021-05-24 | Data analysis system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2021087045A JP2022180119A (en) | 2021-05-24 | 2021-05-24 | Data analysis system |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2022180119A true JP2022180119A (en) | 2022-12-06 |
Family
ID=84327471
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2021087045A Pending JP2022180119A (en) | 2021-05-24 | 2021-05-24 | Data analysis system |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2022180119A (en) |
-
2021
- 2021-05-24 JP JP2021087045A patent/JP2022180119A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10664754B2 (en) | Information processing apparatus | |
CN109816624B (en) | Appearance inspection device | |
US10500721B2 (en) | Machine learning device, laminated core manufacturing apparatus, laminated core manufacturing system, and machine learning method for learning operation for stacking core sheets | |
EP3704550B1 (en) | Generation of a control system for a target system | |
WO2021010342A1 (en) | Action recognition device, action recognition method, and action recognition program | |
JP7349075B2 (en) | Model generation device, system, parameter calculation device, model generation method, parameter calculation method, and program | |
Wu et al. | A physics-informed machine learning model for surface roughness prediction in milling operations | |
CN113989838A (en) | Pedestrian re-recognition model training method, recognition method, system, device and medium | |
JP6283112B2 (en) | Method and apparatus for defining a functional model based on data | |
WO2019235603A1 (en) | Relationship analysis device, relationship analysis method, and recording medium | |
EP4511800A1 (en) | Distortion prediction for additive manufacturing using image analysis | |
Viotti et al. | Damage identification in sandwich structures using Convolutional Neural Networks | |
JP2022180119A (en) | Data analysis system | |
Arima et al. | Visualization and location estimation of defective parts of industrial products using convolutional autoencoder | |
Bui-Ngoc et al. | Structural health monitoring using handcrafted features and convolution neural network | |
Wang et al. | Robot grasping in dense clutter via view-based experience transfer | |
WO2019235370A1 (en) | Learning device, forecasting device, method, and program | |
Ryser et al. | Comparison of linear regression and neural networks as surrogates for sensor modeling on a deep drawn part | |
CN112801201A (en) | Deep learning visual inertial navigation combined navigation design method based on standardization | |
Buechler et al. | Automated geometric analysis of metallic components through picture recognition models for manufacturing technology assessments | |
EP4293334A1 (en) | Crash test device, apparatus, method and computer program for controlling a crash test device and for training a neural network | |
CN118734893B (en) | A method for solving partial differential equations based on multi-step deep neural operator networks | |
US20230339185A1 (en) | Convolution modeling and learning system for predicting geometric shape accuracy of 3d printed products | |
CN110879530A (en) | Method for the secure training of dynamic models | |
EP4521367A1 (en) | A method for forming a machine learning model |