Can you print the value from self.w**self.myParam? I think this line produced Nan because -0.8122^0.5857 is undefined(for other negative values too). Then, every operation involving Nan result in Nan.