khorrams / IGOS_pp

https://igos.eecs.oregonstate.edu/
GNU General Public License v3.0
24 stars 4 forks source link

Error: 'function' object has no attribute 'up' #1

Open unnir opened 3 years ago

unnir commented 3 years ago

Trying to use IGOS for CIFAR10 data set.

IGOS(network, sample.reshape(1,3,32,32).cuda().detach(), baseline.detach(), torch.Tensor([clss]), size = 32)

got this error message:

     63     :return:
     64     """
---> 65     return upscale.up(masks).expand((-1,1,upscale.out_size,upscale.out_size))  # TODO
     66 
     67 

AttributeError: 'function' object has no attribute 'up'

any idea how to fix that?

unnir commented 3 years ago

also, how can one understand this code?

indices[indices] = losses > base_losses[indices] + alphas[indices] * t[indices]

SeanCheng1996 commented 10 months ago

I have the same questions here, and I got an error for this line: indices[indices] = losses > base_losses[indices] + alphas[indices] * t[indices]

Traceback (most recent call last): File "D:\python\summerResearch\IGOS\IGOS_pp-master\main.py", line 168, in gen_explanations(model, data_loader, args) File "D:\python\summerResearch\IGOS\IGOS_pp-master\main.py", line 63, in gen_explanations masks = method( File "D:\python\summerResearch\IGOS\IGOS_pp-master\methods.py", line 369, in iGOS_p alphas = line_search(masks, total_grads, loss_function, alpha) File "D:\python\summerResearch\IGOS\IGOS_pp-master\methods_helper.py", line 179, in line_search indices[indices] = losses > base_losses[indices] + alphas[indices] * t[indices] RuntimeError: unsupported operation: some elements of the input tensor and the written-to tensor refer to a single memory location. Please clone() the tensor before performing the operation.

SeanCheng1996 commented 10 months ago

I changed it as follows without reading the details, it seems working. But I'm not sure if it's the correct thing to do:

#mycode
temp_indices=indices.clone()
indices[temp_indices] = losses > base_losses[indices] + alphas[indices] * t[indices]
# indices[indices] = losses > base_losses[indices] + alphas[indices] * t[indices]

# Same for this, but for if the alpha values are too low (\alpha_l)
temp_indices = indices.clone()
indices[temp_indices] *= (alphas[indices] >= 0.00001)
# indices[indices] *= (alphas[indices] >= 0.00001)