앞서 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을 해결하기 어렵다는 점이다.
$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하게 해결할 수 있다.