1

I have a code in python as follows:

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Experiments for optimizer')
    parser.add_argument('list_experiments', type=str, nargs='+',
                        help='List of experiment names. E.g. CDSGD EASGD FASGD SGD Adam --> will run a training session with each optimizer')
    parser.add_argument('--model_name', default='CNN', type=str,
                        help='Model name: CNN, Big_CNN or FCN')
    parser.add_argument('--batch_size', default=128, type=int,
                        help='Batch size')
    parser.add_argument('--nb_epoch', default=30, type=int,
                        help='Number of epochs')
    parser.add_argument('--dataset', type=str, default="cifar10",
                        help='Dataset, cifar10, cifar100 or mnist')
    parser.add_argument('--n_agents', default=5, type=int,
                        help='Number of agents')
    parser.add_argument('--communication_period', default=1, type=int,
                        help='Gap between the communication of the agents')
    parser.add_argument('--sparsity', default=False, type=bool,
                        help='The connection between agents if sparse or not, default: False i.e. fully connected')
    args = parser.parse_args()

I wanna run it with command

python main.py CDSGD -m CNN -b 512 -ep 200 -d cifar10 -n 5 -cp 1 -s 3

but i get the following error:

main.py: error: unrecognized arguments: -m CNN -b 512 -ep 200 -d cifar10 -n 5 -cp 1 -s 3

how can i fix this problem?

1
  • You never defined any of those short options, e.g., you defined --model_name but not -m. Commented Aug 17, 2019 at 17:30

1 Answer 1

3

A long option can be abbreviated with a unique prefix (e.g., --model will be recognized as --model_name, but short options have to be defined explicitly.

For example,

parser.add_argument('--model_name', '-m', default='CNN', type=str,
                    help='Model name: CNN, Big_CNN or FCN')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.