LoginSignup
0
1

More than 5 years have passed since last update.

link > Learning in Multidimensional Spaces — Neural Networks. Matrix Formulation by Andrew P Paplinski (March 22, 2017)

Last updated at Posted at 2017-03-17

Learning in Multidimensional Spaces — Neural Networks. Matrix Formulation by Andrew P Paplinski
March 22, 2017
http://users.monash.edu/~app/

D次元の入力をM次元の出力にするmappingを学習するNeural Network。

数式ばかりでまったく理解はできていないが、5.4 (Simple) example of function approximationにおいて、2次元の入力、2次元の出力をmappingしている例はある。

実際に学習をした式は以下。

y_1 = x_1 e^{-\rho^2}
y_2 = \frac{sin2\rho^2}{4\rho^2}

where

\rho^2 = x_1^2 + x_2^2

The domain of the function is

x_1, x_2 \in [-2, 2)

In order to form the training set the functions are sampled on a regular 16×16 grid so that the number of datapoints is N = 256.

y1, y2の図示

動作環境
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)

Jupyter code

Paplinski_20170317_Sec5_4.ipynb
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import math
import matplotlib.pyplot as plt
import matplotlib.cm as cm

'''
on Python 2.7.6

v0.1 Mar. 18, 2017
  - show each of (y1,y2) on 2D map 
  - add func2d()  
'''


def func2d(x1, x2):
    rho = x1 ** 2 + x2 ** 2
    y1 = x1 * math.exp(-rho ** 2)
    try:
        y2 = math.sin(2.0 * rho ** 2) / 4.0 / rho **2
    except ZeroDivisionError:
        y2 = 0.0
    return (y1, y2)

y1_1d = np.array([])
y2_1d = np.array([])

for x1idx in range(-20,20,2):
    for x2idx in range(-20,20,2):
        y1,y2 = func2d(x1idx/10, x2idx/10)
        y1_1d = np.append(y1_1d, y1)
        y2_1d = np.append(y2_1d, y2)

siz = 20
dat_2d = np.reshape(y1_1d, (siz,siz))
plt.imshow(dat_2d, extent=(0, siz, 0, siz), cmap=cm.gist_rainbow)
plt.show()
dat_2d = np.reshape(y2_1d, (siz,siz))
plt.imshow(dat_2d, extent=(0, siz, 0, siz), cmap=cm.gist_rainbow)
plt.show()

qiita.png

Figure 5-3: Two functions to be approximatedに掲載されているのはy1のような気がするが、y2はどれだろうか。y1とy2というラベルはある。

MATLABコードのリンクを教えていただいた (He gave me the link to the MATLAB code)。
http://users.monash.edu/~app/Lrn/Mtlb/fap2D.m

そのコード中に以下がある (I found the following)。

surfc([X1-2 X1+2], [X2 X2], [Y1 Y2]), % Two 2-D target functions
                                      % are ploted side by side

X1方向に-2, +2してずらして、Y1とY2を表示していることがわかった (I understand that in the figure Y1 and Y2 are plotted side by side by shifting -2 and +2 in X1 direction)。
Y1の方は下に凸と上に凸のバンプがあり、Y2の方は上に凸のバンプがある。matplotlibの図と整合する (I see that there are bumps downward and upward for Y1 whereas there is a bump upward for Y2). Figure 5-3 has similarities with the figure from matplotlib。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1