Mathematical Reinforcement to the Minibatch of Deep Learning

0 downloads 0 Views 422KB Size Report
Mar 23, 2018 - Advances in Pure Mathematics, 2018, 8, 307-320 http://www.scirp.org/journal/apm. ISSN Online: 2160-0384. ISSN Print: 2160-0368.
Advances in Pure Mathematics, 2018, 8, 307-320 http://www.scirp.org/journal/apm ISSN Online: 2160-0384 ISSN Print: 2160-0368

Mathematical Reinforcement to the Minibatch of Deep Learning Kazuyuki Fujii* International College of Arts and Sciences, Yokohama City University, Yokohama, Japan

How to cite this paper: Fujii, K. (2018) Mathematical Reinforcement to the Minibatch of Deep Learning. Advances in Pure Mathematics, 8, 307-320. https://doi.org/10.4236/apm.2018.83016 Received: February 13, 2018 Accepted: March 20, 2018 Published: March 23, 2018 Copyright © 2018 by author and Scientific Research Publishing Inc. This work is licensed under the Creative Commons Attribution International License (CC BY 4.0). http://creativecommons.org/licenses/by/4.0/ Open Access

Abstract We elucidate a practical method in Deep Learning called the minibatch which is very useful to avoid local minima. The mathematical structure of this method is, however, a bit obscure. We emphasize that a certain condition, which is not explicitly stated in ordinary expositions, is essential for the minibatch method. We present a comprehensive description Deep Learning for non-experts with the mathematical reinforcement.

Keywords Deep Learning, Minibatch, Error (Loss) Function, Local Minima

1. Introduction Deep Learning is one of Machine Learning methods and it has attracted much attention recently. Leaning in general is divided into the supervised learning and unsupervised learning. In this paper we discuss only supervised learning. For general introduction to Deep Learning, see for example [1]. The monographs [2] [3] [4] are standard textbooks. Deep Learning is based on big data, so the supervised learning will give a heavy load to the computer. In order to alleviate the burden we usually use a practical method called the minibatch (a collection of randomly selected small data from big data, see Figure 5). Although the method is commonly used it is not widely understood why it is so effective from the mathematical viewpoint. We point out in Theorem II that a certain condition, which is practically satisfied in ordinary applications, is essential for the effectiveness of the minibatch method. In this paper we present a short and concise review of Deep Learning for *Dedicated to the memory of Professor Ichiro Yokota.

DOI: 10.4236/apm.2018.83016 Mar. 23, 2018

307

Advances in Pure Mathematics

K. Fujii, I. Yokota

non-experts and provide a mathematical reinforcement to the minibatch from the viewpoint of Linear Algebra. Theorem I and II in the text are our main results and some related problems are presented. After reading this paper, readers are encouraged to tackle a remarkable paper [5] which is definitely a monumental achievement.

2. Simple Neural Network As a general introduction to Neuron Dynamics see for example [6] [7].

For non-experts let us draw a neuron model based on the step function S ( x ) . In Figure 1 the set { x1 , x2 , , xn } is the input data, z = S ( y ) is the output

data and the set

{w1 , w2 , , wn }

is the weights of synaptic connections. The

parameter θ is the threshold of the neuron.

Here, z = S ( x ) is a simple step function defined by

0 x < 0 S ( x) =  1 x ≥ 0 Since an algorithm called the backpropagation in Neural Network System uses

derivatives of some activation functions, the simple step function S ( x ) is not suitable. Therefore, we usually use a function called the sigmoid function instead of the step function (see Figure 2). This function is used for a nonlinear compression of data.

Figure 1. Simple neuron model.

Figure 2. Sigmoid function. DOI: 10.4236/apm.2018.83016

308

Advances in Pure Mathematics

K. Fujii, I. Yokota

Definition The sigmoid function is defined by = σ ( x)

1 1 + e− x

( x ∈ R ).

(1)

It is easy to see that the function satisfies

1 ∞) 1 , σ (= 2

σ ( −∞ = 0) ) 0, σ (=

and its derivatives are expressed as polynomials of the original function

= σ ′ ( x ) σ ( x ) (1 − σ ( x ) ) ,

σ ′′ ( x ) =σ ( x ) (1 − σ ( x ) ) (1 − 2σ ( x ) ) .

(2)

The graph is as follows. Comment In Mathematics this is a famous function called the standard logistic function, while in Deep Learning this is called the sigmoid function.

A general logistic function f ( x ) has three parameters { L, λ , x0 } , the overall height L, the parameter λ specifying the inverse width of the transient region

and the location of the center x0 : f ( x) =

L 1+ e

− λ ( x − x0 )

.

The standard logistic function is characterized by = L 1,= λ 1,= x0 0 . See a lecture note [8] as to why the function is so important. Let us draw a neuron model based on the sigmoid function, See Figure 3. The most important thing is to improve the set of weights of the synoptic connections

{w1 , w2 , , wn }

by hard learning. For the purpose we prepare m

input data and teacher signals. In the following we assume m < n and θ = 0 for simplicity. This causes no problem for the present explanation. There is a suitable value of θ for each specific application. For j = 1,2,, m we set

(

Input data : x ( ) = x1( ) , x2( ) , , xn( j

j

j

Teacher signal : d (

j)

)

T

,

j)

where T denotes the transpose of a vector (or a matrix).

Figure 3. Simple neuron model modified. DOI: 10.4236/apm.2018.83016

309

Advances in Pure Mathematics

K. Fujii, I. Yokota

Our method is to determine the weights of synaptic connections which match the output data with given teacher signals as much as possible. For the purpose we consider a square error like

(

1 m ( j) ( j) ∑ d −z 2 j =1

= E E= (w)

), 2

(3)

( )

 n j j j  z ( ) σ= y ( ) σ  ∑ wk xk( )  =  k =1  and determine w = ( w1 , w2 , , wn )

(4)

so that E ( w ) is minimized. We want to realize this purpose by repeated learning. For that we consider a T

discrete dynamical system. Namely, we set

(

(

)

)

2 1 m ( j) ( j)  n  j E= E ( w (t )) = d − z (t ) ; z( ) (t ) = σ y( j ) (t ) = σ  ∑ wk ( t ) xk( j )  (5) ∑ 2 =j 1 = k 1 

for t 0,1,2,, T (∈ N ) . = The initial value w ( 0 ) is given appropriately (not so important).

2.1. Gradient Descent For a general introduction to Gradient Descent see for example [9]. The gradient descent is performed by changing wk ( t ) to wk ( t += 1) wk ( t ) − 

∂E ( w ( t ) ) ∂wk ( t )

( 0 <  < 1)

(6)

and we evaluate the error with the renewed weights

= E E ( w ( t + 1) ) .

This renewal of the weights is the learning process. This is very popular in Mathematics1. We repeat this procedure T steps which is large enough like

E ( w ( 0 ) ) ⇒ E ( w (1) ) ⇒  ⇒ E ( w (T ) ) ≡ E ( w ) .

Let us proceed. We set E = E ( w ) for simplicity (t omitted). From (5) simple calculation gives

∂E = ∂wk

 ∂z ( j )   k  

∑ ( d ( ) − z ( ) )  − ∂w m

j

j

j =1

m

(

)σ  ∑ w x( )  1 − σ  ∑ w x( )  x( )

n j k k =j 1 = k 1= k 1

= −∑ d ( ) − z ( m

j

(

n

j

j

j)

j

k k

k

) x( )σ  ∑ w x( )  1 − σ  ∑ w x( ) 

n n j j k k k = k 1= k 1

= −∑ d ( ) − z (

=j 1

j)

j

k k

and from (6) we obtain wk ( t + 1= ) wk ( t ) − 

∂E ( w ( t ) ) ∂wk ( t )

m

(

= wk ( t ) +  ∑ d ( ) − z (

=j 1

j

j)











( t ) ) xk( j )σ  ∑ wk ( t ) xk( j )  1 − σ  ∑ wk ( t ) xk( j )   . 

n



n

= k 1= k 1



However, to choose  in (6) correctly is a very hard problem.

1

DOI: 10.4236/apm.2018.83016

310

Advances in Pure Mathematics

K. Fujii, I. Yokota

By substituting this into (5) we obtain

 n  j) z( = ( t + 1) σ  ∑ wk ( t + 1) xk( j )   k =1  and the square error becomes

(

)

2 1 m ( j) j d − z ( ) ( t + 1) , ∑ 2 j =1

= E E ( w ( t + 1= ))

which is complicated enough. The renewal of the weights terminates when all 0 , which is a critical point as shown in the next subsection. ∂E ( w ) ∂wk =

2.2. Number of Critical Points Here we evaluate the number of critical points to be encountered in the process. First of all, let us show the definition of a critical point with a simple example.

Definition Let f = f ( x, y, z ) be a smooth function. Then a critical (or ( x0 , y0 , z0 ) is defined by

stationary) point

 f x ( x0 , y0 , z0 ) = 0,   f y ( x0 , y0 , z0 ) = 0,  f ( x , y , z ) = 0.  z 0 0 0

(7)

A critical point is not necessarily a point giving local minimum or local maximum. We make an important assumption with respect to the input data. Assumption (good data) For m < n

{ x ( ) , x ( ) , , x ( ) } 1

2

(8)

m

are linearly independent. The assumption tells that there is a set of integers k1 < k2 <  < km satisfying

xk(1 ) 1

xk(1 )  xk(1 )

xk( 2)

xk( 2 )  xk( 2 )

1

2 2

 xk( m) 1

m

m







≠ 0.

(9)

xk( m)  xk( m ) 2

m

Let us recall

(

(

)

( )) , σ ( y( =) )

1 m ( j) ( j) 2 1 m ( j) j d − z = ∑ d − σ y( ) ∑ 2 j 1= 2j1 = E =

 n  σ  ∑ wk xk( j )  = k 1 

2

j

and try to find if E has a critical point. Suppose E has a critical point at the weights w = {w1 , , wn } , T

(

) ( )

m ∂E j j j j 0= = −∑ d ( ) − z ( ) σ ′ y ( ) xk( ) , k = 1, , n. ∂wk j =1

Let us set

= A( ) j

( d ( ) − z( ) )σ ′ ( y( ) ) j

j

j

for simplicity. The equation can be written as DOI: 10.4236/apm.2018.83016

311

Advances in Pure Mathematics

K. Fujii, I. Yokota m

j j A( ) xk( ) ∑=

0= for k 1, , n

j =1

and it implies m

j j xk( ) A( ) ∑=

0= for k k1 , k2 , , km

j =1

or in matrix form

 xk(1)  1  xk(1)  2    (1)  xk  m

xk(1 )  xk(1 )   A(1)   0      2 m xk( 2 )  xk( 2 )   A( 2 )   0  .  =            ( m)    2 m xk( m)  xk( m )   A   0  2

m

Since the determinant of coefficient matrix is non-zero from (9) we have  A(1)     A( 2 )  =       A( m )   

( (

) ( ) ) ( )

(

) ( )

 d (1) − z (1) σ ′ y (1)     ( 2) ( 2) ( 2)  ′ d −z σ y =        d ( m ) − z ( m ) σ ′ y ( m )   

and

( )) = 0

d ( ) − z( ) = d ( ) − σ y( j

j

j

0   0    0

for j = 1, 2, , m

j

because σ ′ ( y ) ≠ 0 . This means

= E

(

)

1 m ( j) ( j) 2 ∑ d − z = 0. 2 j =1

The result shows that there is no critical point in this process except for

E = 0 . Therefore, when modifying wk ( t )

by the gradient descent (6)

successively there is no danger of being trapped by points taking local minima. Let us summarize the result : Theorem I Under the assumption (8) there is only one global minimum E =0.

Next, let us explain how to choose linearly independent data. We assume that

n is huge and m is sufficiently smaller than n. For m input data

{ x ( ) , x ( ) , , x ( ) } 1

2

m

we consider the m × m Gram’s deterninant x( ) x( )

x( ) x(

2)

x(

x(

2)

1

(

(1)

( 2)

G x , x , , x

(m)

)=

312

2)

x( ) 1

1

2)

 x(

DOI: 10.4236/apm.2018.83016

1

m)

x( 

x( ) 1

x(

m)



x( ) x(

m)



x(

m)

1

2)

 x(

2)



x(

.

 x(

m)

x(

(10)

m)

Advances in Pure Mathematics

K. Fujii, I. Yokota

If m is not large, evaluation of the Gram’s determinant is not so difficult. It is well-known that the input data are linearly independent if the Gram’s determinant is non-zero (see for example [10]). Let us give a short explanation for non-experts. For simplicity we consider the case of m = 3 and set

= x ( ) a= , x ( ) b= , x ( ) c. 1

2

3

Then

and we assume that

a a

a b

a c

G ( a , b, c ) = b a c a

b b c b

b c c c

{a, b, c}

are linearly dependent. For example, we can set

= c αa + βb

(α , β

is real ) .

Short calculation after substituting this into the Gram's determinant above gives a a

a b

a c

b a

b b

b c

α a a +β b a

α a b +β b b

α a c +β b c

G ( a , b, c ) =

and some fundamental operations of determinant give a a a b a c = b a b b b c 0. 0 0 0

= G ( a , b, c )

Namely, we have shown 0. {a, b, c} is linearly dependent ⇒ G ( a, b, c ) =

Taking the contraposition gives G ( a , b, c ) ≠ 0 ⇒ {a , b, c} is linearly independent.

Comment For n > m we denote by M ( n, m; R ) a set of all n × m matrices over R and denote = M n ,m ( R )

{( x

) ∈ M ( n, m; R ) { x( ) , x( ) ,, x( ) } is linearly independent}. (1)

, x ( ) , , x (

1

2

2

m)

m

It is well-known that the subset M n ,m ( R ) is open and dense in M ( n, m; R ) . Therefore, if we choose m vectors from R n randomly they are almost all linearly independent.

3. Deep Neural Network Deep Learning is the heart of Artificial Intelligence (AI) and we provide a concise review for non-experts. Deep Learning is a deep neural network consisting of the input layer (K components), the (multiplex) intermediate layers DOI: 10.4236/apm.2018.83016

313

Advances in Pure Mathematics

K. Fujii, I. Yokota

( M 1 , M 2 ,, N components and the output layer (N components). See Figure 4 (in which= M 1 L= , M 2 M= , M 3 N ).

3.1. Backpropagation First, let us show a figure of deep neural network2 (the figure is short in intermediate layers). Let us explain some notations.

x = ( x1 , x2 , , xK )

T

is the input data. In this case, the weights of synaptic connections are represented by matrices U ,V ,W given by

= U

( u ) ∈ M ( L, K ; R ) , ( v ) ∈ M ( M , L; R ) , (w )∈ M ( N, M ;R) ij

= V

(11)

ij

= W

ij

and our aim is educating these matrices. The synaptic connections are expressed as

ri=

M

∑ wij β j − θ , j =1

i= 1, , N

zi = σ ( ri )

and

qi =

L

∑vijα j − θ , j =1

i= 1, , M

βi = σ ( qi ) and

pi =

K

∑uij x j − θ , j =1

i= 1, , L

α i = σ ( pi ) respectively. See Figure 4 once more. A comment is in order. The flow of data is as follows:

 x1    x x  2  ⇒= = α       xK 

 α1     α2  ⇒ = β      α L 

 β1   β2     βM

   ⇒= z   

 z1     z2  .       zN 

(12)

Now, if

d = ( d1 , d 2 , , d N )

T

is a set of teacher signals, then the square error becomes Figure 4 is of course not perfect because drawing a figure of a big size is not easy.

2

DOI: 10.4236/apm.2018.83016

314

Advances in Pure Mathematics

K. Fujii, I. Yokota

Figure 4. Deep neural network model.

= E E (U= ,V ,W )

1 N 2 ( d k − zk ) . ∑ 2 k =1

Let us consider (discrete) time evolution of the model. For t = 0,1,2, , we must determine

t → t +1 U ( t ) → U ( t + 1) , V ( t ) → V ( t + 1) , W ( t ) → W ( t + 1) , E ( t ) → E ( t + 1)

and we expect E (t ) ≈ 0

if t is large enough (the end of Learning !). Assume now that the system is in the t-th step ,W ( t ) ) E ( t ) E (U ( t ) , V ( t ) = =

2 1 N ∑ ( d k − zk ( t ) ) . 2 k =1

(13)

Then the time evolution of the weights of synaptic connections is determined by the gradient descent: wij ( t + = 1) wij ( t ) −  vij ( t + 1= ) vij ( t ) −  uij ( t + 1= ) uij ( t ) − 

DOI: 10.4236/apm.2018.83016

315

∂E ( t )

∂wij ( t )

∂E ( t )

∂vij ( t ) ∂E ( t )

(14)

,

∂uij ( t )

,

,

Advances in Pure Mathematics

K. Fujii, I. Yokota

which is a natural generalization of that of Section 2.1. Before the calculation let us make a comment on the derivatives of a composite function. Comment Let us explain with a simple example. For a composite function

(

x → f ( x ) → g ( f ( x )) → E g ( f ( x ))

)

the derivative is given by

(

)

dE dE g ( f ( x ) ) dg ( f ( x ) ) df ( x ) = = E′ g ( f ( x )) g ′ ( f ( x )) f ′ ( x ) . dx df ( x ) dx dg ( f ( x ) )

(

)

A composite function is in general complicated, while its derivative is not so complicated.

3.2. Calculation Let us perform the calculation of (14). 1) Case of W ( t ) = ( wij ( t ) ) : From

∂E ( t )

=

∂wij ( t )

∂E ( t ) ∂zi ( t ) ∂ri ( t )

∂zi ( t ) ∂ri ( t ) ∂wij ( t )

= − ( di − zi ( t ) ) σ ′ ( ri ( t ) ) β j ( t )

)

(

= − ( di − zi ( t ) ) σ ( ri ( t ) ) 1 − σ ( ri ( t ) ) β j ( t ) we obtain

(

)

wij ( t + = 1) wij ( t ) +  ( di − zi ( t ) ) σ ( ri ( t ) ) 1 − σ ( ri ( t ) ) β j ( t ) .

2) Case of V ( t ) = ( vij ( t ) ) : From

∂E ( t )

∂vij ( t )

N

=∑ k =1

∂E ( t ) ∂zk ( t ) ∂rk ( t ) ∂βi ( t ) ∂qi ( t )

∂zk ( t ) ∂rk ( t ) ∂βi ( t ) ∂qi ( t ) ∂vij ( t )

N

= −∑ ( d k − zk ( t ) ) σ ′ ( rk ( t ) ) wki ( t ) σ ′ ( qi ( t ) ) α j ( t ) k =1

(

N

= −∑ ( d k − zk ( t ) ) σ ( rk ( t ) ) 1 − σ ( rk ( t ) ) k =1

(

)

)

× wki ( t ) σ ( qi ( t ) ) 1 − σ ( qi ( t ) ) α j ( t ) we have

(

N

vij ( t + 1= ) vij ( t ) +  ∑ ( d k − zk ( t ) ) σ ( rk ( t ) ) 1 − σ ( rk ( t ) ) k =1

(

)

)

× wki ( t ) σ ( qi ( t ) ) 1 − σ ( qi ( t ) ) α j ( t ) .

3) Case of U ( t ) = ( uij ( t ) ) : From ∂E ( t )

∂uij ( t )

N M

= ∑∑

∂E ( t ) ∂zl ( t ) ∂rl ( t ) ∂β k ( t ) ∂qk ( t ) ∂α i ( t ) ∂pi ( t )

k 1 ∂zl ( t ) ∂rl ( t ) ∂β k ( t ) ∂qk ( t ) ∂α i ( t ) ∂pi ( t ) ∂uij ( t ) =l 1 = N M

= −∑∑ ( dl − zl ( t ) ) σ ′ ( rl ( t ) ) wlk ( t ) σ ′ ( qk ( t ) ) vki ( t ) σ ′ ( pi ( t ) ) x j =l 1 = k 1

DOI: 10.4236/apm.2018.83016

316

Advances in Pure Mathematics

K. Fujii, I. Yokota

we have

uij ( t + 1)

(

N M

)

= uij ( t ) +  ∑∑ ( dl − zl ( t ) ) σ ( rl ( t ) ) 1 − σ ( rl ( t ) ) wlk ( t ) =l 1 = k 1

(

)

(

)

×σ ( qk ( t ) ) 1 − σ ( qk ( t ) ) vki ( t ) σ ( pi ( t ) ) 1 − σ ( pi ( t ) ) x j . The calculation so far is based on one input data, for simplicity. However, we must treat a lot of data simultaneously. Let us denote by a the number of data to be considered. For l = 1,2,, a we set

( ), d ( ) = ( d ( ) , d ( ) , , d ( ) ) , z ( ) = ( z ( ) , z ( ) , , z ( ) ) .

x ( ) = x1( ) , x2( ) , , xK( ) l

Input Data

Teacher Signal Output Data

l

l

l

1

l

l

l

l

l 2

l N

l 2

1

l N

T

T

T

By taking all these into consideration the square error function in (13) changes to l l l E ( ) ( t ) ∑  ∑ ( d k( ) − zk( ) ( t ) ) ∑= 2 a

Eˆ ( t ) =

a

1

N



=l 1

=l 1 = k 1

2

  

(15)

at the t-th step. In this case the calculation is very simple. For example, since wij ( t + = 1) wij ( t ) − 

a ∂E ( ) t ∂Eˆ ( t ) () = wij ( t ) −  ∑ ∂wij ( t ) l =1 ∂wij ( t ) l

it is only changed to a

(

) (

)(

(

))

wij ( t + = 1) wij ( t ) +  ∑ di( ) − zi( ) ( t ) σ ri( ) ( t ) 1 − σ ri( ) ( t ) β (j ) ( t ) . l =1

l

l

l

l

l

The calculation for both vij ( t ) and uij ( t ) is quite similar (omitted). In the following we make a mysterious assumption. Assumption We assume that the data in the final step of the intermediate layers are linearly independent:

1) a < M ,

{

2) β ( ) , β ( ) , , β ( 1

2

a)

} are linearly independent.

(16)

See Figure 4 and the flow of data (12). We can show that there is no critical point in our system except for Eˆ = 0 . Therefore, when modifying uij ( t ) , vij ( t ) , wij ( t ) by the gradient descent (14) (replaced by Eˆ ) successively there is no danger of being trapped by points taking local minima. Proof: The proof is essentially the same as that of Section 2.2. However, the proof is the heart of the paper, so we repeat it. A critical point is defined by the equations DOI: 10.4236/apm.2018.83016

317

Advances in Pure Mathematics

K. Fujii, I. Yokota

 ∂Eˆ ( t ) = 0,   ∂wij ( t )  ˆ  ∂E ( t ) = 0,   ∂vij ( t )  ˆ  ∂E ( t ) = 0.  ∂uij ( t )  From (15) we have and set a ∂Eˆ ( t ) l l l l 0= = −∑ di( ) − zi( ) ( t ) σ ′ ri( ) ( t ) β (j ) ( t ) ∂wij ( t ) l =1

(

a

(

) (

) (

)

)

= ∑ β (j ) ( t ) di( ) − zi( ) ( t ) σ ′ ri( ) ( t ) ( − is omitted ) l

l =1 a

l

l

≡ ∑ β (j ) ( t ) Ai( ) l

l

1, 2, , M ) (j=

l

l =1

and it implies a

0 = ∑ β (j ) ( t ) Ai( ) l

l

l =1

( j = j1