ARCS6 AR6-REV.24062600
読み取り中…
検索中…
一致する文字列を見つけられません
SingleLayerPerceptron.hh
[詳解]
1
8//
9// Copyright (C) 2011-2021 Yokokura, Yuki
10// This program is free software;
11// you can redistribute it and/or modify it under the terms of the FreeBSD License.
12// For details, see the License.txt file.
13
14#ifndef SINGLELAYERPERCEPTRON
15#define SINGLELAYERPERCEPTRON
16
17#include <cassert>
18#include <array>
19#include <cmath>
20#include <string>
21#include "Matrix.hh"
22#include "NeuralNetParamDef.hh"
24#include "RandomGenerator.hh"
25#include "Statistics.hh"
26#include "CsvManipulator.hh"
27
28// ARCS組込み用マクロ
29#ifdef ARCS_IN
30 // ARCSに組み込まれる場合
31 #include "ARCSassert.hh"
32 #include "ARCSeventlog.hh"
33#else
34 // ARCSに組み込まれない場合
35 #define arcs_assert(a) (assert(a))
36 #define PassedLog()
37 #define EventLog(a)
38 #define EventLogVar(a)
39#endif
40
41namespace ARCS { // ARCS名前空間
50template <
51 size_t N,
52 size_t P,
53 size_t M,
54 ActvFunc AF,
55 NnInitTypes IT = NnInitTypes::XAVIER,
56 NnDescentTypes GD = NnDescentTypes::MOMENTUM,
57 NnDropout DD = NnDropout::DISABLE
58>
60 public:
63 : u(), U(), W(), b(), l(Matrix<1,M>::ones()), lT(Matrix<M,1>::ones()),
64 delta(), Delta(), fpu(), fpU(), dW(), db(), DW(), Db(),
65 HW(), Hb(), GW(), Gb(),
66 HWhat(), GWhat(), Hbhat(), Gbhat(), SGDcount(0),
67 DropRand(0, 1), DropMask(),
68 xbar(0), sigma(1), eps(0.01), alph(0.9), bet(0.999), NearZero(1e-8), DropRate(0.5)
69 {
70
71 }
72
76 : u(r.u), U(r.U), W(r.W), b(r.b), l(r.l), lT(r.lT),
77 delta(r.delta), Delta(r.Delta), fpu(r.fpu), fpU(r.fpU), dW(r.dW), db(r.db),
78 HW(r.HW), Hb(r.Hb), GW(r.GW), Gb(r.Gb),
82 {
83
84 }
85
90
94 RandomGenerator Rand(0, sigma); // メルセンヌ・ツイスタの生成
95 Rand.GetGaussianRandomMatrix(W);// 平均0,標準偏差σのガウシアン乱数行列の取得
96 }
97
100 void InitWeight(size_t Nprev){
101 if constexpr(IT == NnInitTypes::XAVIER){
102 // Xavierの初期化
103 InitWeightUsingGaussianRandom( 1.0/sqrt((double)Nprev) );
104 }
105 if constexpr(IT == NnInitTypes::HE){
106 // Heの初期化
107 InitWeightUsingGaussianRandom( sqrt(2.0/(double)Nprev) );
108 }
109 }
110
113 void SetGainOfSGD(double epsilon){
114 eps = epsilon;
115 }
116
120 void SetGainOfMomentumSGD(double epsilon, double alpha){
121 eps = epsilon;
122 alph = alpha;
123 }
124
128 void SetGainOfAdaGrad(double epsilon, double zero){
129 eps = epsilon;
130 NearZero = zero;
131 }
132
137 void SetGainOfRMSprop(double epsilon, double alpha, double zero){
138 eps = epsilon;
139 alph = alpha;
140 NearZero = zero;
141 }
142
146 void SetGainOfAdaDelta(double alpha, double zero){
147 alph = alpha;
148 NearZero = zero;
149 }
150
156 void SetGainOfAdam(double epsilon, double alpha, double beta, double zero){
157 eps = epsilon;
158 alph = alpha;
159 bet = beta;
160 NearZero = zero;
161 SGDcount = 0;
162 }
163
166 void SetDropoutRate(double DropoutRate){
167 DropRate = DropoutRate;
168 }
169
174 u = W*zprev + b; // 重み乗算加算とバイアス加算
175 ActivationFunctions::f<AF,1,P>(u, z); // 活性化関数
176
177 if constexpr(DD == NnDropout::ENABLE){
178 // ドロップアウトする場合
179 z = z & DropMask; // 該当ノードをドロップアウト
180 }
181 }
182
187 u = W*zprev + b; // 重み乗算加算とバイアス加算
188 ActivationFunctions::f<AF,1,P>(u, z); // 活性化関数
189
190 if constexpr(DD == NnDropout::ENABLE){
191 // ドロップアウトしていて推定計算する場合
192 z = z*DropRate; // ドロップアウト率で補正
193 }
194 }
195
200 U = W*Zprev + b*lT; // 重み乗算加算とバイアス加算
201 ActivationFunctions::f<AF,M,P>(U, Z); // 活性化関数
202
203 if constexpr(DD == NnDropout::ENABLE){
204 // ドロップアウトする場合
205 Z = Z & (DropMask*lT); // 該当ノードをドロップアウト
206 }
207 }
208
213 U = W*Zprev + b*lT; // 重み乗算加算とバイアス加算
214 ActivationFunctions::f<AF,M,P>(U, Z); // 活性化関数
215
216 if constexpr(DD == NnDropout::ENABLE){
217 // ドロップアウトしていて推定計算する場合
218 Z = Z*DropRate; // ドロップアウト率で補正
219 }
220 }
221
225 void CalcDelta(const Matrix<M,P>& WDeltaNext, Matrix<M,N>& WDelta){
226 ActivationFunctions::fp<AF,M,P>(U, fpU); // 活性化関数の微分を通す計算
227 Delta = fpU & WDeltaNext; // アダマール積の計算
228 if constexpr(DD == NnDropout::ENABLE){
229 // ドロップアウトする場合
230 Delta = Delta & (DropMask*lT); // 該当ノードをドロップアウト
231 }
232 WDelta = tp(W)*Delta; // 前の層に渡すための重み誤差計算
233 }
234
240 Delta = Y - D; // 誤差計算
241 WDelta = tp(W)*Delta; // 前の層に渡すための重み誤差計算
242 }
243
245 void CalcDropout(void){
246 if constexpr(DD == NnDropout::ENABLE){
247 // ドロップアウトするときのみ下記を計算
248 DropRand.GetRandomMatrix(DropMask); // 乱数生成
249
250 // ドロップアウト率よりも大きければマスクを0にする
251 for(size_t i = 0; i < P; ++i){
252 if(DropRate < DropMask.GetElement(1,i+1)){
253 DropMask.SetElement(1,i+1, 0);
254 }else{
255 DropMask.SetElement(1,i+1, 1);
256 }
257 }
258 }
259 }
260
263 void UpdateWeight(const Matrix<M,N>& Zprev){
264 dW = 1.0/M*Delta*tp(Zprev); // 重み更新差分値
265 db = 1.0/M*Delta*l; // バイアス更新差分値
266
267 // 勾配降下法の指定に従ってコンパイル時条件分岐
268 if constexpr(GD == NnDescentTypes::SGD) CalcSGD(dW, db); // 確率的勾配降下法
269 if constexpr(GD == NnDescentTypes::MOMENTUM)CalcMomentumSGD(dW, db);// モーメンタム確率的勾配降下法
270 if constexpr(GD == NnDescentTypes::ADAGRAD) CalcAdaGrad(dW, db); // AdaGrad勾配降下法
271 if constexpr(GD == NnDescentTypes::RMSPROP) CalcRMSprop(dW, db); // RMSprop勾配降下法
272 if constexpr(GD == NnDescentTypes::ADADELTA)CalcAdaDelta(dW, db); // AdaDelta勾配降下法
273 if constexpr(GD == NnDescentTypes::ADAM) CalcAdam(dW, db); // Adam勾配降下法
274 }
275
277 void DispWeight(void){
278 PrintMatrix(W, "% 16.14e");
279 }
280
282 void DispBias(void){
283 PrintMatrix(b, "% 16.14e");
284 }
285
287 void DispSettings(void){
288 printf("xbar = % 16.14e\n", xbar); // データセット正規化(標準化)用の平均値
289 printf("sigma = % 16.14e\n", sigma); // データセット正規化(標準化)用の標準偏差
290 printf("eps = % 16.14e\n", eps); // 更新ゲイン(SGD, Momentum, AdaGrad, RMSprop)
291 printf("alph = % 16.14e\n", alph); // 更新ゲイン(Momentum, RMSprop, AdaDelta)
292 printf("bet = % 16.14e\n", bet); // 更新ゲイン(Adam)
293 printf("NearZero = % 16.14e\n", NearZero); // ゼロ割回避用のゼロに近い値
294 printf("DropRate = % 16.14e\n", DropRate); // ドロップアウト率
295 }
296
301 double GetLoss(const Matrix<M,P>& Y, const Matrix<M,P>& D){
302 // 活性化関数によって損失関数を変える
303 double E = 0;
304 if constexpr(AF == ActvFunc::SOFTMAX){
305 E = GetCrossEntropy(Y, D); // 損失関数 クロスエントロピー版
306 }else{
307 Matrix<1,P> DeltaBar;
308 Statistics::MeanRow(Y - D, DeltaBar); // ミニバッチ内の平均ベクトルを計算
309 const Matrix<1,1> e = tp(DeltaBar)*DeltaBar/2.0;// 損失関数 内積版
310 E = e[1];
311 }
312 return E;
313 }
314
319 double GetCrossEntropy(const Matrix<M,P>& Y, const Matrix<M,P>& D){
320 return -sumall(D & loge(Y))/(double)M; // Softmaxのクロスエントロピー
321 }
322
325 template <size_t NN, size_t MM>
327 xbar = Statistics::Mean(x); // 平均の計算
328 sigma = Statistics::StandardDeviation(x); // 標準偏差の計算
329 x = (x - xbar)/sigma; // データセットを正規化(標準化)
330 }
331
335 x = (x - xbar)/sigma; // データセットのときの値に基づいて入力を正規化(標準化)
336 }
337
341 void SaveWeightAndBias(const std::string& WeightName, const std::string& BiasName){
342 CsvManipulator::SaveFile(W, WeightName); // 重み行列を名前を付けて保存
343 CsvManipulator::SaveFile(b, BiasName); // バイアスベクトルを名前を付けて保存
344 }
345
349 void LoadWeightAndBias(const std::string& WeightName, const std::string& BiasName){
350 CsvManipulator::LoadFile(W, WeightName); // 重み行列を読み込み
351 CsvManipulator::LoadFile(b, BiasName); // バイアスベクトルを読み込み
352 }
353
356 void SaveSettings(const std::string& SettingName){
357 Matrix<1,7> S; // 設定格納用ベクトル
358 S.Set(xbar, sigma, eps, alph, bet, NearZero, DropRate); // 設定値を格納
359 CsvManipulator::SaveFile(S, SettingName); // CSVファイルに保存
360 }
361
364 void LoadSettings(const std::string& SettingName){
365 Matrix<1,7> S; // 設定格納用ベクトル
366 CsvManipulator::LoadFile(S, SettingName); // CSVファイルから読み込み
367 S.Get(xbar, sigma, eps, alph, bet, NearZero, DropRate); // 設定値を読み込み
368 }
369
370 private:
372 const SingleLayerPerceptron& operator=(const SingleLayerPerceptron&) = delete;
373
374 protected:
397 size_t SGDcount;
400 double xbar;
401 double sigma;
402 double eps;
403 double alph;
404 double bet;
405 double NearZero;
406 double DropRate;
407
411 void CalcSGD(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
412 DW = -eps*DiffW; // 更新ゲイン乗算後の重み更新差分値
413 Db = -eps*Diffb; // 更新ゲイン乗算後のバイアス更新差分値
414 W += DW; // 重み行列の更新
415 b += Db; // バイアスベクトルの更新
416 }
417
421 void CalcMomentumSGD(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
422 DW = alph*DW - eps*DiffW; // 更新ゲイン乗算後の重み更新差分値
423 Db = alph*Db - eps*Diffb; // 更新ゲイン乗算後のバイアス更新差分値
424 W += DW; // 重み行列の更新
425 b += Db; // バイアスベクトルの更新
426 }
427
431 void CalcAdaGrad(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
432 HW += DiffW & DiffW;
433 Hb += Diffb & Diffb;
434 DW = -eps*(DiffW % (sqrte(HW) + NearZero));
435 Db = -eps*(Diffb % (sqrte(Hb) + NearZero));
436 W += DW; // 重み行列の更新
437 b += Db; // バイアスベクトルの更新
438 }
439
443 void CalcRMSprop(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
444 HW = alph*HW + (1.0 - alph)*(DiffW & DiffW);
445 Hb = alph*Hb + (1.0 - alph)*(Diffb & Diffb);
446 DW = -eps*(DiffW % (sqrte(HW) + NearZero));
447 Db = -eps*(Diffb % (sqrte(Hb) + NearZero));
448 W += DW; // 重み行列の更新
449 b += Db; // バイアスベクトルの更新
450 }
451
455 void CalcAdaDelta(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
456 // 重みのAdaDeltaの計算
457 HW = alph*HW + (1.0 - alph)*(DiffW & DiffW);
458 DW = -(sqrte(GW + NearZero) % sqrte(HW + NearZero)) & DiffW;
459 GW = alph*GW + (1.0 - alph)*(DW & DW);
460
461 // バイアスのAdaDeltaの計算
462 Hb = alph*Hb + (1.0 - alph)*(Diffb & Diffb);
463 Db = -(sqrte(Gb + NearZero) % sqrte(Hb + NearZero)) & Diffb;
464 Gb = alph*Gb + (1.0 - alph)*(Db & Db);
465
466 W += DW; // 重み行列の更新
467 b += Db; // バイアスベクトルの更新
468 }
469
473 void CalcAdam(const Matrix<N,P>& DiffW, const Matrix<1,P>& Diffb){
474 ++SGDcount; // イタレーションカウンタ
475
476 // 重みのAdamの計算
477 HW = alph*HW + (1.0 - alph)*DiffW;
478 GW = bet*GW + (1.0 - bet)*(DiffW & DiffW);
479 HWhat = HW/(1.0 - pow(alph, SGDcount));
480 GWhat = GW/(1.0 - pow(bet, SGDcount));
481 DW = -eps*( HW % (sqrte(GWhat) + NearZero) );
482
483 // バイアスのAdamの計算
484 Hb = alph*Hb + (1.0 - alph)*Diffb;
485 Gb = bet*Gb + (1.0 - bet)*(Diffb & Diffb);
486 Hbhat = Hb/(1.0 - pow(alph, SGDcount));
487 Gbhat = Gb/(1.0 - pow(bet, SGDcount));
488 Db = -eps*( Hb % (sqrte(Gbhat) + NearZero) );
489
490 W += DW; // 重み行列の更新
491 b += Db; // バイアスベクトルの更新
492 }
493};
494}
495
496#endif
497
ARCS イベントログクラス
ARCS用ASSERTクラス
CSVファイル操作クラス
乱数生成器
行列/ベクトル計算クラス(テンプレート版)
#define PrintMatrix(a, b)
行列要素表示マクロ(フォーマット指定あり版)
Definition Matrix.hh:35
活性化関数
ActvFunc
活性化関数のタイプの定義
Definition ActivationFunctions.hh:35
ニューラルネットワークパラメータ定義ファイル
NnInitTypes
重み初期化のタイプの定義
Definition NeuralNetParamDef.hh:19
NnDropout
ドロップアウトの定義
Definition NeuralNetParamDef.hh:35
NnDescentTypes
勾配降下法のタイプの定義
Definition NeuralNetParamDef.hh:25
static void f(const Matrix< N, M > &U, Matrix< N, M > &Y)
活性化関数
Definition ActivationFunctions.hh:118
static void fp(const Matrix< N, M > &U, Matrix< N, M > &Y)
活性化関数の微分
Definition ActivationFunctions.hh:177
static void SaveFile(const std::array< double, M > &Data, const std::string &FileName)
1次元std::arrayをCSVファイルに書き出す関数
Definition CsvManipulator.hh:54
static void LoadFile(std::array< T, M > &Data, const std::string &FileName)
CSVファイルから1次元std::arrayに読み込む関数
Definition CsvManipulator.hh:72
行列/ベクトル計算クラス(テンプレート版)
Definition Matrix.hh:44
constexpr TT GetElement(size_t n, size_t m) const
指定した要素番号の値を返す関数
Definition Matrix.hh:489
constexpr void Set(const T1 &u1, const T2 &... u2)
行列要素に値を設定する関数
Definition Matrix.hh:385
constexpr void SetElement(size_t n, size_t m, TT val)
指定した要素番号に値を設定する関数
Definition Matrix.hh:480
constexpr void Get(T1 &u1, T2 &... u2)
行列要素から値を読み込む関数
Definition Matrix.hh:405
乱数生成器
Definition RandomGenerator.hh:22
void GetGaussianRandomMatrix(Matrix< N, M > &Y)
ガウシアン乱数行列を生成する関数
Definition RandomGenerator.hh:88
void GetRandomMatrix(Matrix< N, M > &Y)
乱数行列を生成する関数
Definition RandomGenerator.hh:77
単層パーセプトロンクラス
Definition SingleLayerPerceptron.hh:59
double GetCrossEntropy(const Matrix< M, P > &Y, const Matrix< M, P > &D)
クロスエントロピーを返す関数
Definition SingleLayerPerceptron.hh:319
Matrix< M, P > fpU
活性化関数の微分を通した後の行列
Definition SingleLayerPerceptron.hh:384
Matrix< 1, P > Gb
AdaDelta, Adam用
Definition SingleLayerPerceptron.hh:392
Matrix< N, P > HW
AdaGrad, RMSprop, Adam用
Definition SingleLayerPerceptron.hh:389
size_t SGDcount
Adam勾配降下法用のカウンタ
Definition SingleLayerPerceptron.hh:397
void UpdateWeight(const Matrix< M, N > &Zprev)
重み行列とバイアスベクトルの更新
Definition SingleLayerPerceptron.hh:263
void DispSettings(void)
パーセプトロン設定値の表示
Definition SingleLayerPerceptron.hh:287
Matrix< N, P > dW
重み更新差分値
Definition SingleLayerPerceptron.hh:385
void SaveSettings(const std::string &SettingName)
パーセプトロンの設定をCSVファイルに保存する関数
Definition SingleLayerPerceptron.hh:356
Matrix< N, P > GWhat
Adam用
Definition SingleLayerPerceptron.hh:394
Matrix< 1, P > db
バイアス更新差分値
Definition SingleLayerPerceptron.hh:386
void InitWeight(size_t Nprev)
重み行列の初期化
Definition SingleLayerPerceptron.hh:100
void CalcAdam(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
Adam勾配降下法
Definition SingleLayerPerceptron.hh:473
void LoadWeightAndBias(const std::string &WeightName, const std::string &BiasName)
重み行列とバイアスベクトルをCSVファイルとして入力する関数
Definition SingleLayerPerceptron.hh:349
void CalcForwardForTraining(const Matrix< 1, N > &zprev, Matrix< 1, P > &z)
順伝播計算(ベクトル入出力訓練版)
Definition SingleLayerPerceptron.hh:173
~SingleLayerPerceptron()
デストラクタ
Definition SingleLayerPerceptron.hh:87
void SetGainOfMomentumSGD(double epsilon, double alpha)
モーメンタム確率的勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:120
void NormalizeInput(Matrix< 1, P > &x)
入力データの正規化(標準化)
Definition SingleLayerPerceptron.hh:334
Matrix< M, P > U
状態行列
Definition SingleLayerPerceptron.hh:376
Matrix< 1, P > DropMask
ドロップアウト用マスクベクトル
Definition SingleLayerPerceptron.hh:399
void NomalizeDataset(Matrix< NN, MM > &x)
生計測データセットの正規化(標準化)
Definition SingleLayerPerceptron.hh:326
void CalcAdaDelta(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
AdaDelta勾配降下法
Definition SingleLayerPerceptron.hh:455
Matrix< N, P > GW
AdaDelta, Adam用
Definition SingleLayerPerceptron.hh:391
void CalcAdaGrad(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
AdaGrad勾配降下法
Definition SingleLayerPerceptron.hh:431
void CalcRMSprop(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
RMSprop勾配降下法
Definition SingleLayerPerceptron.hh:443
Matrix< N, P > W
重み行列
Definition SingleLayerPerceptron.hh:377
double alph
更新ゲイン(Momentum, RMSprop, AdaDelta)
Definition SingleLayerPerceptron.hh:403
Matrix< 1, P > b
バイアスベクトル
Definition SingleLayerPerceptron.hh:378
void SaveWeightAndBias(const std::string &WeightName, const std::string &BiasName)
重み行列とバイアスベクトルをCSVファイルとして出力する関数
Definition SingleLayerPerceptron.hh:341
void SetGainOfSGD(double epsilon)
確率的勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:113
void SetGainOfRMSprop(double epsilon, double alpha, double zero)
RMSprop勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:137
void CalcDropout(void)
ドロップアウトマスクの計算
Definition SingleLayerPerceptron.hh:245
Matrix< 1, P > fpu
活性化関数の微分を通した後のベクトル
Definition SingleLayerPerceptron.hh:383
void DispBias(void)
バイアスベクトルの表示
Definition SingleLayerPerceptron.hh:282
void CalcForwardForEstimation(const Matrix< 1, N > &zprev, Matrix< 1, P > &z)
順伝播計算(ベクトル入出力推定版)
Definition SingleLayerPerceptron.hh:186
Matrix< 1, P > Gbhat
Adam用
Definition SingleLayerPerceptron.hh:396
Matrix< 1, P > delta
誤差ベクトル
Definition SingleLayerPerceptron.hh:381
double DropRate
ドロップアウト率
Definition SingleLayerPerceptron.hh:406
void CalcForwardForTraining(const Matrix< M, N > &Zprev, Matrix< M, P > &Z)
順伝播計算(ミニバッチ訓練版)
Definition SingleLayerPerceptron.hh:199
double NearZero
ゼロ割回避用のゼロに近い値
Definition SingleLayerPerceptron.hh:405
Matrix< M, P > Delta
誤差行列
Definition SingleLayerPerceptron.hh:382
void CalcSGD(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
ヴァニラ確率的勾配降下法
Definition SingleLayerPerceptron.hh:411
void SetDropoutRate(double DropoutRate)
ドロップアウト率の設定
Definition SingleLayerPerceptron.hh:166
Matrix< 1, P > u
状態ベクトル
Definition SingleLayerPerceptron.hh:375
Matrix< 1, P > Hbhat
Adam用
Definition SingleLayerPerceptron.hh:395
void InitWeightUsingGaussianRandom(const double sigma)
重み行列の正規分布乱数による初期化
Definition SingleLayerPerceptron.hh:93
double bet
更新ゲイン(Adam)
Definition SingleLayerPerceptron.hh:404
void CalcMomentumSGD(const Matrix< N, P > &DiffW, const Matrix< 1, P > &Diffb)
モーメンタム確率的勾配降下法
Definition SingleLayerPerceptron.hh:421
Matrix< N, P > HWhat
Adam用
Definition SingleLayerPerceptron.hh:393
Matrix< 1, P > Db
更新ゲイン乗算後のバイアス更新差分値
Definition SingleLayerPerceptron.hh:388
void SetGainOfAdaGrad(double epsilon, double zero)
AdaGrad勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:128
void SetGainOfAdam(double epsilon, double alpha, double beta, double zero)
Adam勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:156
Matrix< N, P > DW
更新ゲイン乗算後の重み更新差分値
Definition SingleLayerPerceptron.hh:387
SingleLayerPerceptron(SingleLayerPerceptron &&r)
ムーブコンストラクタ
Definition SingleLayerPerceptron.hh:75
Matrix< 1, M > l
1ベクトル
Definition SingleLayerPerceptron.hh:379
RandomGenerator DropRand
ドロップアウト用メルセンヌ・ツイスタ
Definition SingleLayerPerceptron.hh:398
double sigma
データセット正規化(標準化)用の標準偏差
Definition SingleLayerPerceptron.hh:401
void CalcForwardForEstimation(const Matrix< M, N > &Zprev, Matrix< M, P > &Z)
順伝播計算(ミニバッチ推定版)
Definition SingleLayerPerceptron.hh:212
void SetGainOfAdaDelta(double alpha, double zero)
AdaDelta勾配降下法の更新ゲイン(学習率)の設定
Definition SingleLayerPerceptron.hh:146
double GetLoss(const Matrix< M, P > &Y, const Matrix< M, P > &D)
訓練/テスト誤差を返す関数
Definition SingleLayerPerceptron.hh:301
Matrix< 1, P > Hb
AdaGrad, RMSprop, Adam用
Definition SingleLayerPerceptron.hh:390
SingleLayerPerceptron()
コンストラクタ
Definition SingleLayerPerceptron.hh:62
void CalcDeltaForOutputLayer(const Matrix< M, P > &Y, const Matrix< M, P > &D, Matrix< M, N > &WDelta)
出力層用の誤差行列の計算
Definition SingleLayerPerceptron.hh:239
void CalcDelta(const Matrix< M, P > &WDeltaNext, Matrix< M, N > &WDelta)
入力層と内部層(隠れ層)用の誤差行列の計算
Definition SingleLayerPerceptron.hh:225
Matrix< M, 1 > lT
1ベクトルの転置
Definition SingleLayerPerceptron.hh:380
void DispWeight(void)
重み行列の表示
Definition SingleLayerPerceptron.hh:277
double eps
更新ゲイン(SGD, Momentum, AdaGrad, RMSprop)
Definition SingleLayerPerceptron.hh:402
double xbar
データセット正規化(標準化)用の平均値
Definition SingleLayerPerceptron.hh:400
void LoadSettings(const std::string &SettingName)
CSVファイルからパーセプトロンの設定を読み込む関数
Definition SingleLayerPerceptron.hh:364
static void MeanRow(const Matrix< N, M > &U, Matrix< 1, M > &y)
行列Uの横方向の平均を計算して縦ベクトルを出力する関数
Definition Statistics.hh:57
static double StandardDeviation(const Matrix< N, M > &U)
行列U全体の標準偏差を求める
Definition Statistics.hh:244
static double Mean(const Matrix< N, M > &U)
行列U全体の平均を計算する
Definition Statistics.hh:43