我正在尝试在C中实现多层感知器库,我想从命令行使用标志-H设置隐藏层的数量以及每一层中感知器的数量,其中第一个数字是隐藏的数量层和接下来的下2个数字分别是该2层中的神经元数量,我正在使用getopt()例如,如果我想创建一个包含2个隐藏层(每个包含5个神经元)的网络,我将输入:-H 2 5 5对于分别具有5、4和3个神经元的3层,我将通过-H 3 5 4 3
while ((opt = getopt(argc, argv, ":d:i:o:h:")) != -1) {
switch (opt) {
case 'd':
printf("dataset file: %s\n", optarg);
break;
case 'i':
printf("number of inputs: %s\n", optarg);
break;
case 'h':
// Help need parsing the options here
break;
case 'o':
printf("number of outputs %s\n", optarg);
break;
case '?':
printf("Unknown option: %c\n", optopt);
break;
case ':':
printf("Missing arg for %c\n", optopt);
break;
}
}
-h 2 5 4 3
选项,请考虑以下代码,该代码操纵optind以跳过'-h'之后的多余值。