The error is raised, because you are defining self.layer_number after calling self.compute_actions, which already tries to access this attribute.
Move the assignment of self.layer_number before calling compute_actions and it should work.