-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83c7a18
commit 5937256
Showing
6 changed files
with
102 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from train import train | ||
from eval import eval | ||
import argparse | ||
|
||
|
||
def main(args): | ||
if args.subcommand == 'train': | ||
train( | ||
train_set_size=args.trainsetsize[0] if args.trainsetsize[0]!=0 else 0.8, | ||
batch_size=args.batchsize[0] if args.batchsize else 1000, | ||
lr=args.learningrate[0] if args.learningrate else 0.0001, | ||
epochs=args.epochs[0] if args.epochs else 10, | ||
is_verbose=args.verbose if args.verbose else True, | ||
weight_decay=args.weightdecay[0] if args.weightdecay else 0.9, | ||
retrain=False | ||
) | ||
elif args.subcommand == 'retrain': | ||
train( | ||
train_set_size=0.8, | ||
batch_size=10, | ||
lr=0.0001, | ||
epochs=1, | ||
is_verbose=args.verbose if args.verbose else True, | ||
weight_decay=0.8, | ||
retrain=True, | ||
grace=args.grace[0] if args.grace else 0 | ||
) | ||
elif args.subcommand == 'eval': | ||
eval( | ||
image=args.image[0] | ||
) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
subparsers = parser.add_subparsers(dest='subcommand') | ||
|
||
parser_train = subparsers.add_parser('train') | ||
parser_retrain = subparsers.add_parser('retrain') | ||
parser_eval = subparsers.add_parser('eval') | ||
|
||
parser_train.add_argument('-ts', '--trainsetsize', nargs=1, type=float, choices=[x/10 for x in range(0, 10)], help='Train set split size', required=True) | ||
parser_train.add_argument('-bs', '--batchsize', nargs=1, type=int, help='Size of the training batch', required=False) | ||
parser_train.add_argument('-lr', '--learningrate', nargs=1, type=float, help='Learning rate', required=False) | ||
parser_train.add_argument('-e', '--epochs', nargs=1, type=int, help='Number of epochs', required=False) | ||
parser_train.add_argument('-v', '--verbose', nargs=1, type=bool, help='Verbose mode on/off', required=False) | ||
parser_train.add_argument('-wd', '--weightdecay', nargs=1, type=float, help='Weight decay (L2 regularization)', required=False) | ||
|
||
parser_retrain.add_argument('-g', '--grace', nargs=1, type=float, choices=[x/10 for x in range(0, 11)], help='Proportion of old memes to consider again', required=False) | ||
parser_retrain.add_argument('-v', '--verbose', nargs=1, type=bool, help='Verbose mode on/off', required=False) | ||
|
||
parser_eval.add_argument('-i', '--image', nargs=1, help='Image to evaluate', required=True) | ||
|
||
args = parser.parse_args() | ||
|
||
main(args) | ||
|
||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters