AttributeError: can't set attribute ???
wangxiao5791509 opened this issue · 8 comments
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?
hi,have you solve this problem?
@Yaoyuanzhou No.
okay,thanks
I get the same problem. How do you solve this?
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.
same problem.
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.