ShotaArima / demo-lowprofool

0 stars 0 forks source link

deepFool #20

Closed ShotaArima closed 1 month ago

ShotaArima commented 1 month ago

What?(変更の概要・何を変更したのか)

/tmp/ipykernel_605/2400241947.py in gen_adv(config, method) 31 orig_pred, adv_pred, x_adv, loop_i = lowProFool(x_tensor, model, weights, encodedbounds, maxiters, alpha, lambda) 32 elif method == 'Deepfool': ---> 33 orig_pred, adv_pred, x_adv, loop_i = deepfool(x_tensor, model, maxiters, alpha, encoded_bounds, weights=[]) 34 else: 35 raise Exception("Invalid method", method)

/src/Adverse.py in deepfool(x_old, net, maxiters, alpha, bounds, weights, overshoot) 264 265 pert_x = x_old + (1 + overshoot) * torch.from_numpy(r_tot) --> 266 pert_x = clip(pert_x, min_bounds, max_bounds) 267 268 x = Variable(pert_x, requires_grad=True)

/src/Adverse.py in clip(current, low_bound, up_bound) 18 # サイズが一致していることを確認 ... ---> 20 assert current.size() == low_bound.size() == up_bound.size(), f"Sizes must match: current {current.size()}, low_bound {low_bound.size()}, up_bound {up_bound.size()}" 21 22 clipped = torch.max(torch.min(current, up_bound), low_bound)

AssertionError: Sizes must match: current torch.Size([1, 25]), low_bound torch.Size([12]), up_bound torch.Size([12]) Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings...


### 解釈
- 以下のテンソルサイズが不一致である
  - current: torch.Size([1, 25])
  - low_bound: torch.Size([12])
  - up_bound: torch.Size([12])

## Why?(なぜ変更するのか)

- 研究用のソースコードとして、クリティカルな問題である

## How?(どう変更するのか)
- lowprofool側と最低限同じよな前処理を行う
  - テンソルサイズは25にする

## Checklist

- [ ] a
- [ ] b