MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / main

Function main

modelzoo/dlrm/train.py:581–700  ·  view source on GitHub ↗
(tf_config=None, server=None)

Source from the content-addressed store, hash-verified

579
580
581def main(tf_config=None, server=None):
582 # check dataset and count data set size
583 print("Checking dataset...")
584 train_file = args.data_location
585 test_file = args.data_location
586 if args.parquet_dataset and not args.tf:
587 train_file += '/train.parquet'
588 test_file += '/eval.parquet'
589 else:
590 train_file += '/train.csv'
591 test_file += '/eval.csv'
592 if (not os.path.exists(train_file)) or (not os.path.exists(test_file)):
593 print("Dataset does not exist in the given data_location.")
594 sys.exit()
595 no_of_training_examples = 0
596 no_of_test_examples = 0
597 if args.parquet_dataset and not args.tf:
598 import pyarrow.parquet as pq
599 no_of_training_examples = pq.read_table(train_file).num_rows
600 no_of_test_examples = pq.read_table(test_file).num_rows
601 else:
602 no_of_training_examples = sum(1 for line in open(train_file))
603 no_of_test_examples = sum(1 for line in open(test_file))
604 print("Numbers of training dataset is {}".format(no_of_training_examples))
605 print("Numbers of test dataset is {}".format(no_of_test_examples))
606
607 # set batch size, eporch & steps
608 batch_size = math.ceil(
609 args.batch_size / args.micro_batch
610 ) if args.micro_batch and not args.tf else args.batch_size
611
612 if args.steps == 0:
613 no_of_epochs = 1
614 train_steps = math.ceil(
615 (float(no_of_epochs) * no_of_training_examples) / batch_size)
616 else:
617 no_of_epochs = math.ceil(
618 (float(batch_size) * args.steps) / no_of_training_examples)
619 train_steps = args.steps
620 test_steps = math.ceil(float(no_of_test_examples) / batch_size)
621 print("The training steps is {}".format(train_steps))
622 print("The testing steps is {}".format(test_steps))
623
624 # set fixed random seed
625 tf.set_random_seed(args.seed)
626
627 # set directory path
628 model_dir = os.path.join(args.output_dir,
629 'model_DLRM_' + str(int(time.time())))
630 checkpoint_dir = args.checkpoint if args.checkpoint else model_dir
631 print("Saving model checkpoints to " + checkpoint_dir)
632
633 # create data pipline of train & test dataset
634 train_dataset = build_model_input(train_file, batch_size, no_of_epochs)
635 test_dataset = build_model_input(test_file, batch_size, 1)
636
637 dataset_output_types = tf.data.get_output_types(train_dataset)
638 dataset_output_shapes = tf.data.get_output_shapes(test_dataset)

Callers 1

train.pyFile · 0.70

Calls 14

sumFunction · 0.85
exitMethod · 0.80
timeMethod · 0.80
from_structureMethod · 0.80
build_model_inputFunction · 0.70
build_feature_columnsFunction · 0.70
DLRMClass · 0.70
trainFunction · 0.70
evalFunction · 0.70
formatMethod · 0.45
joinMethod · 0.45
get_nextMethod · 0.45

Tested by

no test coverage detected