-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
77 lines (64 loc) · 2.22 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from argparse import ArgumentParser
import logging
import sys
from train import train # Import your training function from train.py
def setup_logging():
"""Set up logging configuration."""
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] - %(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
)
def main(args):
setup_logging()
# Log the start of the training process
logging.info("Starting the training process...")
# Call the training function from train.py
train(args) # Pass other hyperparameters as needed
# Log the end of the training process
logging.info("Training process completed.")
if __name__ == "__main__":
parser = ArgumentParser(
description="Train a neural network.",
epilog="Example usage:\n" " python3 main.py --categories PER ORG LOC",
conflict_handler="resolve",
)
# Model specific arguments
parser.add_argument(
"--learning-rate",
type=float,
default=5e-5,
help="Learning rate for the optimizer.",
)
parser.add_argument(
"--batch-size", type=int, default=32, help="Batch size for training."
)
parser.add_argument(
"--epochs", type=int, default=1, help="Number of training epochs."
)
parser.add_argument(
"--model-name",
type=str,
default="prajjwal1/bert-tiny",
help="Specify which model to fine-tune",
)
parser.add_argument("--gpu", action="store_true", help="Enable GPU usage.")
# Data specific arguments.
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
"--language-filter",
type=str,
default=None,
help="When specified, all other languages are filtered from the dataset",
)
group.add_argument(
"--categories",
nargs="+",
type=str,
default=None,
help="When specified, all other categories are filtered from the dataset. Provide a whitespace separated list of categories",
)
args = parser.parse_args()
if args.language_filter and args.categories:
parser.error("Both --language-filter and --categories can not be specified.")
main(args)