Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: can't set attribute ??? #4

Closed
wangxiao5791509 opened this issue Jun 12, 2019 · 8 comments
Closed

AttributeError: can't set attribute ??? #4

wangxiao5791509 opened this issue Jun 12, 2019 · 8 comments

Comments

@wangxiao5791509
Copy link

Hi, when I run the code, I meet the following errors:
"AttributeError: can't set attribute". and I checked the code of data pre-process script:

trainset_new.train_data = train_data_sub.clone()
trainset_new.train_labels = train_labels_sub.clone()

but in the "sub.py" file, the class "subMNIST" do not define this attribute, how do you run the code successfully?

@Yaoyuanzhou
Copy link

hi,have you solve this problem?

@wangxiao5791509
Copy link
Author

@Yaoyuanzhou No.

@Yaoyuanzhou
Copy link

okay,thanks

@SadAngelF
Copy link

I get the same problem. How do you solve this?

@SadAngelF
Copy link

@SadAngelF
Copy link

I get the reason.
@Property is viewed as the private Attributes. So, it can't be assigned values in code by an explicit way, like A.data=1. So it raised the wrong, AttributeError: can't set attribute.

@hyhy01
Copy link

hyhy01 commented Jun 24, 2020

same problem.

@semihcanturk
Copy link

Use this instead:

trainset_new.data = train_data_sub.clone()
trainset_new.targets = train_labels_sub.clone()

The properties @SadAngelF mentions only returns the data/targets anyways - they're basically deprecated:

@property
def train_data(self):
    warnings.warn("train_data has been renamed data")
    return self.data

@property
def train_labels(self):
    warnings.warn("train_labels has been renamed targets")
    return self.targets

Meanwhile, self.data and self.targets are not properties, and can be edited as mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants