ニューラルネットワーク

主に機械学習で用いられる、人間の脳神経を模したモデルの一種

: neural network; NN[1][1][2] (: artificial neural network) 

[1]

概要

編集
 
生物のニューロン

 (axon)  (dendrite) [3](synapse)[3][1]Dendrite, Axon [1][2]
 

[1] [4][1][4]

weightsw

[1]appleorange[1]調[1]調orange[1]  調[4]


 

: : 

 


/: 



[3]

歴史

編集

19431949   "  " [5]

1967[6]10[5]

1970[5][5]1986  [5]

年表

編集

1943

1958

1969

1979使

1982

1985

1986

1988[7]1989使[8][9]LeCun

2006[10][11]2010

代表的な人工ニューラルネットワーク

編集

順伝播型ニューラルネットワーク

編集

: Feed-forward Neural Network; FFN, FFNN[12]

FFN/FFNFFN

並列計算

編集

FFNがもつ特徴に並列計算がある。回帰結合をもつネットワークはシーケンシャルに処理を繰り返す必要があるため、1データに対して時間方向に並列計算できない[13]。FFNは層内で並列計算が可能であり、RNNと比較して容易に並列計算機(例: GPU)の計算能力を上限まで引き出せる[注釈 4]

 
多層パーセプトロンの模式図

RBFネットワーク

編集

誤差逆伝播法に用いられる活性化関数放射基底関数を用いたニューラルネットワーク

自己組織化写像

編集

自己組織化写像はコホネンが1982年に提案した教師なし学習モデルであり、多次元データのクラスタリング、可視化などに用いられる。自己組織化マップ、コホネンマップとも呼ばれる。

 
畳み込みニューラルネットワーク

畳み込みニューラルネットワーク

編集

畳み込みニューラルネットワークとは層間が全結合ではない順伝播型ニューラルネットワークの一種。

画像を対象とするために用いられることが多い。

再帰型ニューラルネットワーク(リカレントニューラルネット、フィードバックニューラルネット)

編集

フィードフォワードニューラルネットと違い、双方向に信号が伝播するモデル。すべてのノードが他の全てのノードと結合を持っている場合、全結合リカレントニューラルネットと呼ぶ。シーケンシャルなデータに対して有効で、自然言語処理音声動画の解析などに利用される[14]

Transformer

編集

Self-Attention[13][13]

使[15]

確率的ニューラルネット

編集

乱数による確率的な動作を導入した人工ニューラルネットワークモデル。モンテカルロ法のような統計的標本抽出手法と考えることができる。

スパイキングニューラルネットワーク

編集

ニューラルネットワークをより生物学的な脳の働きに近づけるため、活動電位(スパイク)を重視して作られた人工ニューラルネットワークモデル。スパイクが発生するタイミングを情報と考える。ディープラーニングよりも扱える問題の範囲が広い次世代技術と言われている。ニューラルネットワークの処理は逐次処理のノイマン型コンピュータでは処理効率が低く、活動電位まで模倣する場合には処理効率がさらに低下するため、実用する際には専用プロセッサとして実装される場合が多い。

2015年現在、スパイキングNN処理ユニットを積んだコンシューマー向けのチップとしては、QualcommSnapdragon 820が登場する予定となっている[16][17]

複素ニューラルネットワーク

編集

入出力信号やパラメータ(重み閾値)が複素数値であるようなニューラルネットワークで活性化関数は必然的に複素関数になる[18]

利点

編集



22[18]3



23[5][18][19]

生成モデル/統計モデル

編集

生成モデル(統計モデルとも)は、データが母集団の確率分布に従って生成されると仮定しそのパラメータを学習するニューラルネットワークの総称である。統計的機械学習の一種といえる。モデル(=母集団)からのサンプリングによりデータ生成が可能な点が特徴である(詳しくは推計統計学 § 統計モデル機械学習 § 統計的機械学習)。

自己回帰型生成ネット

編集

 

Autoregressive Generative Network § PixelCNNWaveNetWaveRNN=CNNWaveNet沿RNNWaveRNN

変分オートエンコーダ

編集

変分オートエンコーダ (VAE) とは、ネットワークA(エンコーダ)が確率分布のパラメータを出力し、ネットワークB(デコーダ)が確率分布から得られた表現をデータへと変換するモデルである。画像・音楽生成におけるVQ-VAE-2がその例である。

敵対的生成ネットワーク

編集

敵対的生成ネットワーク (Generative Adversarial Network, GAN) とは、ガウシアン等の確率分布から得られたノイズをネットワークA (Generator) がデータへ変換し、ネットワークBが母集団からサンプリングされたデータとネットワークAの出力を見分けるように学習するモデルである。DCGANやStyleGAN、BigGANがその例である。

flow-based生成モデル

編集

flow-based生成モデルはFlow、Glow、NICE、realNVP等が存在する。

構成要素

編集

ニューラルネットワークは様々な要素を組み合わせからなる。各構成要素は経験的・理論的に示された特徴をニューラルネットワークへもたらしている。

Table. ニューラルネットワークの構成要素
総称/名称 概念 意図/効果
skip connection x = x + f(x) 勾配消失の防止 ResNet
アンサンブル学習 ResNet
位置情報の保持 U-Net
ボトルネック構造 Wshallow > Wmiddle < Wdeep 特徴抽出 AE
圧縮された潜在表現 generative AE
階層構造 middle(x) = f(x + bottom(x)) 局所/全体特徴の両立[20] U-Net GAN
一貫性

consistency

cycle GB2A(GA2B(a)) = a コンテンツ/不変特徴の保持 CycleGAN
latent D(G(z)) = D(G(z+Δ)) 潜在変数ゆらぎへの堅牢性 ICR-BigGAN
データ拡張 D(Aug(x)) = D(x)

D(G(z)) = D(Aug(G(z)))

leakのないデータ拡張 CR-GAN

ICR-BigGAN

progressive output Size(Gt=0(x)) < Size(Gt=1(x)) 学習の高速化・安定化[21] PGGAN
input Input Complexity t0 < t1 学習の高速化・安定化 PA-GAN
正規化 batch y = γc Norm(x) + βc 学習の高速化
layer
instance
group
Conditional y = γcnl,s Norm(c) + βcnl,s スタイル変換
AdaIN y = σ(s) Norm(c) + μ(s) スタイル変換 StyleGAN
SPADE スタイル変換

バッチ正規化

編集

: Batch Normalization[22]/BNμ, σ (β, γ)  y = γX+β

CNNLayer NormInstance NormGroup NormβγNN(β)NN(γ)

活性化関数

編集


学習

編集





 (gradient-free method) [2]

実装

編集

 + ;  [23] Level 2 BLAS  Level 3 BLAS [24]

実装例

編集

3    ReLU使

3XYT      

 

使

 

   T  

 

Python 3.5 Python @ **  * 
import numpy as np

dim_in = 1              # 入力は1次元
dim_out = 1             # 出力は1次元
hidden_count = 1024     # 隠れ層のノードは1024個
learn_rate = 0.005      # 学習率

# 訓練データはxは -1~1yは 2 * x ** 2 - 1
train_count = 64        # 訓練データ数
train_x = np.arange(-1, 1, 2 / train_count).reshape((train_count, dim_in))
train_y = np.array([2 * x ** 2 - 1 for x in train_x]).reshape((train_count, dim_out))

# 重みパラメータ。-0.5 〜 0.5 でランダムに初期化。この行列の値を学習する。
w1 = np.random.rand(hidden_count, dim_in) - 0.5
w2 = np.random.rand(dim_out, hidden_count) - 0.5
b1 = np.random.rand(hidden_count) - 0.5
b2 = np.random.rand(dim_out) - 0.5

# 活性化関数は ReLU
def activation(x):
    return np.maximum(0, x)

# 活性化関数の微分
def activation_dash(x):
    return (np.sign(x) + 1) / 2

# 順方向。学習結果の利用。
def forward(x):
    return w2 @ activation(w1 @ x + b1) + b2

# 逆方向。学習
def backward(x, diff):
    global w1, w2, b1, b2
    v1 = (diff @ w2) * activation_dash(w1 @ x + b1)
    v2 = activation(w1 @ x + b1)

    w1 -= learn_rate * np.outer(v1, x)  # outerは直積
    b1 -= learn_rate * v1
    w2 -= learn_rate * np.outer(diff, v2)
    b2 -= learn_rate * diff

# メイン処理
idxes = np.arange(train_count)          # idxes は 0~63
for epoc in range(1000):                # 1000エポック
    np.random.shuffle(idxes)            # 確率的勾配降下法のため、エポックごとにランダムにシャッフルする
    error = 0                           # 二乗和誤差
    for idx in idxes:
        y = forward(train_x[idx])       # 順方向でxからyを計算する
        diff = y - train_y[idx]         # 訓練データとの誤差
        error += diff ** 2              # 二乗和誤差に蓄積
        backward(train_x[idx], diff)    # 誤差を学習
    print(error.sum())                  # エポックごとに二乗和誤差を出力。徐々に減衰して0に近づく。

推論

編集

ニューラルネットワークの学習(ディープラーニング)と対比して、ニューラルネットワークによる演算は推論: inference)と呼ばれる。

ハードウェアアクセラレーション

編集

ニューラルネットワークの推論を高速化する様々なハードウェアアクセラレーションAPIが提案・実装されている[25]。GPUにおけるCUDAWindowsにおけるDirectML[26]NVIDIAにおけるTensorRT[27]などが挙げられる。

量子化

編集

: Quantizationweightactivation[28][29]8-bitFP32INT8

[30]

: FP32INT8:IPC1AVX-FP32: 8AVX2-INT8: 32

:   

: [31]

: 

: -

QDQ[32][33] 

 
  • 静的量子化(: Static Quantization): 代表的データを用いた量子化パラメータの事前算出[34]
  • 動的量子化(: Dynamic Quantization): 各実行ステップのactivation値に基づくactivation用量子化パラメータの動的な算出[35](weightは実行前に量子化[36]
  • fake quantization (Quantize and DeQuantize; QDQ): 量子化+脱量子化( )。学習時の量子化模倣[37]あるいは量子化オペレータの表現[38]

スパース化

編集

: Sparsification



:   

: 

: 

: 



: Pruning

脚注

編集

注釈

編集


(一)^ 

(二)^ 11

(三)^ 2020

(四)^ RNN1stepGPU使

(五)^ BP使

出典

編集
  1. ^ a b c d e f g h i j Charu C.Aggarwal著『ニューラルネットワークとディープラーニング』(データサイエンス大系シリーズ)、学術図書出版社、2022年。ISBN 978-4780607147, 第一章「ニューラルネットワークとは」「はじめに」、pp.1-2
  2. ^ 『2020年版 基本情報技術者 標準教科書』オーム社、p.55
  3. ^ a b 平塚秀雄『よくわかる脳神経外科学』金原出版、1996, pp.14-15「神経細胞とニューロン」
  4. ^ a b c 平野廣美『C++とJavaでつくるニューラルネットワーク』パーソナルメディア株式会社、2008、p.27「学習することは重みが変わること」
  5. ^ a b c d e 平野廣美『C++とJavaでつくるニューラルネットワーク』パーソナルメディア株式会社、2008、pp.9-10「はじめに」
  6. ^ John C. Eccles, Masao Ito, János Szentágothai(1967), The Cerebellum as a Neuronal Machine, (Springer, New York) [1]
  7. ^ Homma, Toshiteru; Les Atlas; Robert Marks II (1988). “An Artificial Neural Network for Spatio-Temporal Bipolar Patters: Application to Phoneme Classification”. Advances in Neural Information Processing Systems 1: 31–40. http://papers.nips.cc/paper/20-an-artificial-neural-network-for-spatio-temporal-bipolar-patterns-application-to-phoneme-classification.pdf. 
  8. ^ Yann Le Cun (June 1989). Generalization and Network Design Strategies. http://yann.lecun.com/exdb/publis/pdf/lecun-89.pdf. 
  9. ^ Y. LeCun; B. Boser; J. S. Denker; D. Henderson; R. E. Howard; W. Hubbard; L. D. Jackel (1989). “Backpropagation applied to handwritten zip code recognition”. Neural Computation 1 (4): 541-551. 
  10. ^ Reducing the Dimensionality of Data with Neural Networks
  11. ^ A fast learning algorithm for deep belief nets
  12. ^ "A nonrecurrent network has no cycles. Nonrecurrent networks can be thought of as computing an input-output function." Jordan, M.I. (1986). Serial order: A parallel distributed processing approach. (Tech. Rep. No. 8604). San Diego: University of California, Institute for Cognitive Science.
  13. ^ a b c Vaswani et al. 2017, p. 6001.
  14. ^ Yu, Yong; Si, Xiaosheng; Hu, Changhua; Zhang, Jianxun (2019-07-01). “A Review of Recurrent Neural Networks: LSTM Cells and Network Architectures”. Neural Computation 31 (7): 1235–1270. doi:10.1162/neco_a_01199. ISSN 0899-7667. https://doi.org/10.1162/neco_a_01199. 
  15. ^ Vaswani, Ashish; Shazeer, Noam; Parmar, Niki; Uszkoreit, Jakob; Jones, Llion; Gomez, Aidan N.; Kaiser, Lukasz; Polosukhin, Illia (2017-12-05). “Attention Is All You Need”. arXiv:1706.03762 [cs]. http://arxiv.org/abs/1706.03762. 
  16. ^ Neuromorphic Processing : A New Frontier in Scaling Computer Architecture Qualcomm 2014年
  17. ^ Qualcomm’s cognitive compute processors are coming to Snapdragon 820 ExtremeTech 2015年3月2日
  18. ^ a b c 複素ニューラルネットワーク
  19. ^ Akira Hirose, Shotaro Yoshida (2012). “Generalization Characteristics of Complex-valued Feedforward Neural Networks in Relation to Signal Coherence”. IEEE TNNLS 23 (4): 541-551. 
  20. ^ The proposed U-Net based architecture allows to provide detailed per-pixel feedback to the generator while maintaining the global coherence of synthesized images
  21. ^ starting from a low resolution, we add new layers that model increasingly fine details as training progresses. This both speeds the training up and greatly stabilizes it PGGAN paper
  22. ^ "making normalization a part of the model architecture and performing the normalization for each training mini-batch." Sergey Ioffe, et. al.. (2015)
  23. ^ "ニューラルネットワークの演算の基本は、多入力の積和演算である。" 百瀬 (2016). 第2章:ディープ・ニューラルネットワークのニューロチップへの実装~その勘所は!!. semiconportal.
  24. ^ "深層学習の…フレームワーク中では, 計算時間の多くが畳み込み計算などの密行列積に費やされており … 計算時間の約90%が畳み込み層での計算時間であることが知られている" p.1 of 関谷, et al. (2017). 低ランク近似を用いた深層学習の行列積の高速化. 情報処理学会研究報告. Vol2017-HPC-158, No.24.
  25. ^ Optimize and Accelerate Machine Learning Inferencing and Training. ONNX Runtime.
  26. ^ "Direct Machine Learning (DirectML) is a low-level API for machine learning." Direct Machine Learning (DirectML). Microsoft.
  27. ^ "TensorRT can optimize and deploy applications to the data center, as well as embedded and automotive environments. It powers key NVIDIA solutions" NVIDIA TensorRT. NVIDIA.
  28. ^ "Quantization works by reducing the precision of the numbers used to represent a model's parameters, which by default are 32-bit floating point numbers." Model optimization. TensorFlow.
  29. ^ "Quantizing a network means converting it to use a reduced precision integer representation for the weights and/or activations." DYNAMIC QUANTIZATION. PyTorch.
  30. ^ "Quantization performance gain comes in 2 part: instruction and cache." Quantize ONNX Models. ONNX Runtime.
  31. ^ "Less memory usage: Smaller models use less RAM when they are run, which frees up memory for other parts of your application to use, and can translate to better performance and stability." Model optimization. TensorFlow.
  32. ^ "Old hardware doesn’t have or has few instruction support for byte computation. And quantization has overhead (quantize and dequantize), so it is not rare to get worse performance on old devices." Quantize ONNX Models. ONNX Runtime.
  33. ^ "Performance improvement depends on your model and hardware." Quantize ONNX Models. ONNX Runtime.
  34. ^ "Static quantization quantizes the weights and activations of the model. ... It requires calibration with a representative dataset to determine optimal quantization parameters for activations." QUANTIZATION. PyTorch.
  35. ^ "with dynamic quantization ... determine the scale factor for activations dynamically based on the data range observed at runtime." DYNAMIC QUANTIZATION. PyTorch.
  36. ^ "The model parameters ... are converted ahead of time and stored in INT8 form." DYNAMIC QUANTIZATION. PyTorch.
  37. ^ "Simulate the quantize and dequantize operations in training time." FAKEQUANTIZE. PyTorch. 2022-03-15閲覧.
  38. ^ "There are 2 ways to represent quantized ONNX models: ... Tensor Oriented, aka Quantize and DeQuantize (QDQ)." Quantize ONNX Models. ONNX RUNTIME. 2022-03-15閲覧.

参考文献

編集

関連項目

編集

外部リンク

編集