Reliable and Interpretable Artificial Intelligence-Lecture 2 (Adversarial Examples solving)

Serendipity·2023년 12월 19일
0

2023 LeSN

목록 보기
51/52

개요

이 강의에서는 다양한 영역의 공격 사례(adversarial attacks)를 살펴보고 적대적 공격과 적대적 예제 생성(adversarial example generation)에 중점을 둡니다.

목표

The concept of transferability(이전가능성) of generated adversarial examples and two types of attacks
Fast Gradient Sign Method (FGSM)
Optimization challenges and constraint using proxy functions

상세

적대적 공격, 방어, 실험적 견고성 및 수학적 인증과 같은 주제를 논의합니다. 또한 정확성과 견고성 사이의 트레이드오프와 수학적 인증이 AI 시스템의 안전을 보장하는 데 잠재력을 갖고 있다는 점을 언급합니다.

Problem (1~3)

Problem 1



Problem 2

Problem 3

η를 찾아서 식 최소화하기

Exercise #2

import torch
import torch.nn as nn

# 동일한 초기화가 항상 같은 결과를 보이도록 시드 고정
torch.manual_seed(1)

# 설명된 대로 모델 N 생성
N = nn.Sequential(nn.Linear(10, 10, bias=False),
                  nn.ReLU(),
                  nn.Linear(10, 10, bias=False),
                  nn.ReLU(),
                  nn.Linear(10, 3, bias=False))

# 첫 번째 차원은 배치 크기이며, 그 다음 차원은 실제 데이터의 차원입니다.
x = torch.rand((1, 10))
# x에 대한 기울기 계산을 활성화하여 기울기를 계산할 수 있도록 합니다.
x.requires_grad_()
# 목표 클래스
t = 1
# 데이터에 따라 이 값은 크거나 작을 수 있습니다.
epsReal = 0.4

# 부동소수점 오류를 보정하기 위한 작은 상수
eps = epsReal - 1e-7

print("원래 클래스: ", N(x).argmax(dim=1).item())
assert(N(x).argmax(dim=1).item() == 2)

# 기울기 계산
# CrossEntropyLoss()는 교차 엔트로피 손실과 암시적 소프트맥스 함수를 결합합니다.
L = nn.CrossEntropyLoss()
loss = L(N(x), torch.tensor([t], dtype=torch.long))
loss.backward()

# 여기에 코드를 작성하세요.
# x.grad에는 x에 대한 손실의 기울기가 저장되어 있습니다.
xBar = x

print("새로운 클래스: ", N(xBar).argmax(dim=1).item())
assert(N(xBar).argmax(dim=1).item() == 1)
assert(torch.norm((x-xBar), p=float('inf')) <= epsReal)
profile
I'm an graduate student majoring in Computer Engineering at Inha University. I'm interested in Machine learning developing frameworks, Formal verification, and Concurrency.

0개의 댓글