Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unnecessary binary search? #16

@kmidtlid

Description

@kmidtlid

Could you explain the difference between the binary search in the initialize method [1] and the binary search right after it [2]? It seems to me that the second one is unnecessary, since the image already has been projected to the boundary.

[1] Binary search in the initialize method

HSJA/hsja.py

Lines 288 to 300 in daecd5c

# Binary search to minimize l2 distance to original image.
low = 0.0
high = 1.0
while high - low > 0.001:
mid = (high + low) / 2.0
blended = (1 - mid) * sample + mid * random_noise
success = decision_function(model, blended[None], params)
if success:
high = mid
else:
low = mid
initialization = (1 - high) * sample + high * random_noise

[2] Binary search right after initialize

HSJA/hsja.py

Lines 81 to 86 in daecd5c

# Project the initialization to the boundary.
perturbed, dist_post_update = binary_search_batch(sample,
np.expand_dims(perturbed, 0),
model,
params)
dist = compute_distance(perturbed, sample, constraint)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions