Apologies if the title did not make any sense because I don't know how else to phrase it. I would like to know if there is a way to pass all my arguments args
into self
and be able to call the arguments in self without typing self.args.
For example, in the following I pass args
to self.args
but I'll need to type self.args.units
if I want to access the variable units.
class model(nn.Module):
def __init__(self, args):
super(model, self).__init__()
self.args = args
print(self.args.units)
Is there a way for me to call self.units
without having to pass args.units
to self.units
?
print(self.units)
args
are the arguments I pass in when calling the program.
parser = argparse.ArgumentParser()
parser.add_argument('--player_attention_type', type=str)
parser.add_argument('--player_velocity_encoder_units', nargs="*", type=int)
args = parser.parse_args()
question from:
https://stackoverflow.com/questions/65860286/how-to-pass-all-arguments-to-self-and-remove-args 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…