I hope you can assist me with this simple issue (but for some reason won't resolve). I tried adding an attribute to the class pso in pso_adam.py. In other words, I added self.weight_flag to the list of variables in __init__(), but whenever I try to use it inside fitness_fn(self, x) or any other function, the compiler throws this error:
'pso' object has no attribute 'weight_flag'
I checked my indentation and I tried multiple editors. I also tried renaming the class to 'pso_adam'. None of these trials resolved the error, but I can't seem to know what is causing the error.
My question is: If I want tot add more attributes to the pso class in pso_adam.py, what is the best way to do it?
It seems the right approach.
The fitness_fn function is called during the initialization, though.
Make sure to declare the new attribute before calling it.
Hello @caio-davi,
I hope you can assist me with this simple issue (but for some reason won't resolve). I tried adding an attribute to the class
pso
inpso_adam.py
. In other words, I addedself.weight_flag
to the list of variables in__init__()
, but whenever I try to use it insidefitness_fn(self, x)
or any other function, the compiler throws this error:'pso' object has no attribute 'weight_flag'
I checked my indentation and I tried multiple editors. I also tried renaming the class to 'pso_adam'. None of these trials resolved the error, but I can't seem to know what is causing the error.
My question is: If I want tot add more attributes to the pso class in
pso_adam.py
, what is the best way to do it?Thanks again for this great work.