diff --git a/kim_cnn/main.py b/kim_cnn/main.py index 0017a96..0e88410 100644 --- a/kim_cnn/main.py +++ b/kim_cnn/main.py @@ -11,10 +11,6 @@ import os if __name__=='__main__': import argparse - torch.manual_seed(3435) - np.random.seed(3435) - if torch.cuda.is_available(): - torch.cuda.manual_seed(3435) argparser = argparse.ArgumentParser() @@ -22,12 +18,20 @@ if __name__=='__main__': argparser.add_argument('--validate', action='store_true') argparser.add_argument('--test', action='store_true') argparser.add_argument('--load', action='store_true') + argparser.add_argument('--seed', help='Random seed', type=int, default=3435) + argparser.add_argument('--num_threads', help='The number of threads to use', type=int, default=4) args, extra_args = argparser.parse_known_args() # args.train = True/False ... # extra_args['--some': "xxxx"] cargs = {k: v for (k, v) in vars(Configurable.argparser.parse_args(extra_args)).items() if v is not None} + torch.manual_seed(args.seed) + np.random.seed(args.seed) + if torch.cuda.is_available(): + torch.cuda.manual_seed(args.seed) + torch.set_num_threads(args.num_threads) + if 'model_type' not in cargs: print("You need to specify the model_type") exit() @@ -78,4 +82,4 @@ if __name__=='__main__': print(network.test(validate=True)) elif args.test: print("### The accuracy for test set: ") - print(network.test(validate=False)) \ No newline at end of file + print(network.test(validate=False)) diff --git a/sm_cnn/main.py b/sm_cnn/main.py index ec2c4c0..d9d7c25 100644 --- a/sm_cnn/main.py +++ b/sm_cnn/main.py @@ -118,11 +118,12 @@ if __name__ == "__main__": ap.add_argument("--dash-split", help="split words containing hyphens", action="store_true") ap.add_argument("--index-for-corpusIDF", help="fetches idf from Index. provide index path. will\ generate a vocabFile") + ap.add_argument('--seed', help='Random seed', type=int, default=1234) args = ap.parse_args() - torch.manual_seed(1234) - np.random.seed(1234) + torch.manual_seed(args.seed) + np.random.seed(args.seed) torch.set_num_threads(args.num_threads) train_set, dev_set, test_set = 'train-all', 'raw-dev', 'raw-test'