It gives me the following error
File “make_sample_data.py”, line 149, in
main(args)
File “make_sample_data.py”, line 132, in main
if args.load_pretrained:
AttributeError: ‘NoneType’ object has no attribute ‘load_pretrained’
Could you check, which attributes args contains?
I just tried to argparse code and it’s working correctly and returns True as the default for args.load_pretrained.
it is not printing anything and showing same error
Traceback (most recent call last):
File “make_sample_data.py”, line 150, in
main(args)
File “make_sample_data.py”, line 131, in main
if args.load_pretrained:
AttributeError: ‘NoneType’ object has no attribute ‘load_pretrained’
In that case the get_args method returns None and I don’t know why this would be the case.
Are you running your script in a Jupyter notebook? If so, could you use a terminal and rerun the script?
Sorry, in that case I don’t know what might be causing this issue, as this code snippet successfully returns the default arguments:
def get_args():
parser = argparse.ArgumentParser("parameters")
parser.add_argument('--p', type=int, default=10, help='P being a parameter accounting for the fact that we expect only a few number of relevant classes to occur in each image. (default: 10)')
parser.add_argument('--k', type=int, default=1000, help=', there is an important trade-off on K that strongly depends on the ratio K/M. (default: 1000)')
parser.add_argument('--batch-size', type=int, default=100, help='batch size, (default: 100)')
parser.add_argument('--input-size', type=tuple, default=(32, 32), help='input data size, (default: (32, 32))')
parser.add_argument('--load-pretrained', type=bool, default=True)
args = parser.parse_args()
return args
args = get_args()
print(args)
> Namespace(batch_size=100, input_size=(32, 32), k=1000, load_pretrained=True, p=10)
print(args.load_pretrained)
> True
It seems that your current environment isn’t able to parse the arguments and based on this I would recommend to post the issue (without the PyTorch code) on e.g. StackOverflow.