I'm trying to override two parent class functions train
and eval
in a ChildClass
. In the parent class, eval()
basically calls train()
. However, I realize that when I write my code as below, eval()
in the parent class is trying to call the function train()
in ChildClass
- I would like eval()
in the parent class to call train()
in the parent class instead.
I'm just wondering if there is any clean solutions to make changes to ChildClass
that would allow the parent class to call the parent train()
function?
class ChildClass(nn.Module):
def __init__(self):
super(ChildClass, self).__init__()
def train(self):
super(ChildClass, self).train()
def eval(self):
super(ChildClass, self).eval()
Parent class is in a Python Package (pytorch
), so no changes should be made:
class Module(object):
#...
def train(self, mode=True):
# ...
return self
def eval(self):
return self.train(False)