M-ADDA icon indicating copy to clipboard operation
M-ADDA copied to clipboard

AttributeError: 'int' object has no attribute 'clone'

Open redhat12345 opened this issue 7 years ago • 12 comments

I got the following error.

File "/media/redhat/DATA/M-ADDA/datasets/uspsBig.py", line 69, in getitem img, label = self.X[index].clone(), self.y[index].clone() AttributeError: 'int' object has no attribute 'clone'

redhat12345 avatar Jul 23 '18 00:07 redhat12345

Are you using Pytorch 0.4? if you have Pytorch 0.4 or higher self.y[index] will be a tensor instead of an integer, which then allows you to apply the function .clone() to it

IssamLaradji avatar Jul 23 '18 00:07 IssamLaradji

Thanks.

redhat12345 avatar Jul 24 '18 22:07 redhat12345

Awesome, did it work after upgrading to 0.4?

IssamLaradji avatar Jul 25 '18 20:07 IssamLaradji

Thanks for the reply. Yeah it's working now.

redhat12345 avatar Jul 25 '18 23:07 redhat12345

Hi, May I know how you plot the graph for your paper? May I get the code for plotting graph, please?

redhat12345 avatar Jul 26 '18 00:07 redhat12345

Thanks for the interest! are you referring to the plot in Figure 9? I used PrettyPlots as uploaded here: https://github.com/IssamLaradji/PrettyPlots

IssamLaradji avatar Jul 26 '18 15:07 IssamLaradji

Actually, I am talking about figure 3 and 8 in the paper.

redhat12345 avatar Jul 31 '18 07:07 redhat12345

I generated Figure 8 using the visEmbed(exp_dict) function in addons/vis.py. I generated Figure 3 using visdom scatter plot https://github.com/facebookresearch/visdom

Cheers.

IssamLaradji avatar Jul 31 '18 22:07 IssamLaradji

@IssamLaradji May I know how you draw the Figure 8?

redhat12345 avatar Sep 26 '18 06:09 redhat12345

@IssamLaradji When I run the following command, I got the following error:

$ python vis.py File "vis.py", line 11, in import datasets ImportError: No module named 'datasets'

Traceback (most recent call last): File "vis.py", line 16, in import models ImportError: No module named 'models'

redhat12345 avatar Sep 26 '18 06:09 redhat12345

@redhat12345 are you using Python 3? if you are using Python 2 then you get this error you mentioned because it does not use absolute import (it uses relative import instead).

I generated Figure 8 using the visEmbed(exp_dict) function in addons/vis.py.

IssamLaradji avatar Sep 26 '18 11:09 IssamLaradji

@IssamLaradji I am using Python 3. When I run the command: $ python3 addons/vis.py

It gives me some warning this time and did not produce any images in the Summarises folder that i created here.

"/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 return f(*args, **kwds) /usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 "

redhat12345 avatar Sep 28 '18 08:09 redhat12345