Moving to neural networks

앞서 AEs와 robust optimization이 linear model에서 작동하는 맥락을 알아봤으니 이번에는 deep neural network에서의 possibility에 대해 알아보자.

다시 inner maximization problem을 살펴보자.

Neural networks의 경우 linear models 보다 loss surface가 훨씬 "irregular"하기 때문에 더 challenging하다. 아래 코드를 통해 simple (randomly trained) model과 simple linear function을 비교해보자.

import torch
import torch.nn as nn
import torch.optim as optim

torch.manual_seed(0) # random seed를 고정하기 위한 함수
model = nn.Sequential(nn.Linear(1,100), nn.ReLU(), 
                      nn.Linear(100,100), nn.ReLU(), 
                      nn.Linear(100,100), nn.ReLU(), 
                      nn.Linear(100,1))
opt = optim.SGD(model.parameters(),lr=1e-2)
for _ in range(100):
    loss = nn.MSELoss()(model(torch.randn(100,1)), torch.randn(100,1))
    opt.zero_grad()
    loss.backward()
    opt.step()
                      
plt.plot(np.arange(-3,3,0.01), model(torch.arange(-3,3,0.01)[:,None]).detach().numpy())
plt.xlabel("Input")
plt.ylabel("Output")

이러한 loss surface의 특징으로 인해 2가지 어려움이 있다.

첫번째는 neural network에서는 small perturbation이 들어가도 loss 가 엄청나게 increase한다는 점이다.

두번째는 linear case와는 달리 inner maximization problem을 해결하기 어렵다는 점이다.

Strategies for the inner maximization

$h_\theta$가 neural network 일 때 inner optimization problem을 푸는 방법?

$$ \underset{||\delta||\leq\epsilon}{\text{maximize}} \ell(h_\theta(x),y) $$

lower bounds, exact solutions, 그리고 upper bounds에 따른 3가지 전략으로 inner optimization problem을 approximate하게 해결할 수 있다.

  1. Lower bound : feasible한 $\delta$ 는 lower bound를 제시한다. 그리고 이는 "Empirical하게 optimization problem을 해결하는 것", "AE를 찾는것"과 같은 의미가 된다.
  2. Exact solution : Challenging. Mixed integer programming 등의 technique으로 해결할 수 있지만 이를 large model로 확장하여 푸는 것은 매우 어렵다. 하지만 몇몇 small model에 한해서는 inner maximization problem에 대한 exact solution을 construct 할 수 있다.
  3. Upper bound : 네트워크 구조의 relaxation을 이용하는 것이 핵심이다. Relaxed version의 경우 original network의 정보를 포함하고 있으면서 optimize하기 쉬운 구조로 되어있다.