-
Notifications
You must be signed in to change notification settings - Fork 561
update selfplay to write 5% of games to a holdout directory #57
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,7 @@ def evaluate( | |
def selfplay( | ||
load_file: "The path to the network model files", | ||
output_dir: "Where to write the games"="data/selfplay", | ||
holdout_dir: "Where to write the games"="data/holdout", | ||
output_sgf: "Where to write the sgfs"="sgf/", | ||
readouts: 'How many simulations to run per move'=100, | ||
verbose: '>=2 will print debug info, >=3 will print boards' = 1, | ||
|
@@ -138,8 +139,15 @@ def selfplay( | |
with gfile.GFile(os.path.join(output_sgf, '{}.sgf'.format(output_name)), 'w') as f: | ||
f.write(player.to_sgf()) | ||
|
||
fname = os.path.join(output_dir, "{}.tfrecord.zz".format(output_name)) | ||
preprocessing.make_dataset_from_selfplay(game_data, fname) | ||
tf_examples = preprocessing.make_dataset_from_selfplay(game_data) | ||
|
||
# Hold out 5% of games for evaluation. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make 0.05 a flag? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gilding the lily a bit but done :) |
||
if random.random() < 0.05: | ||
fname = os.path.join(holdout_dir, "{}.tfrecord.zz".format(output_name)) | ||
else: | ||
fname = os.path.join(output_dir, "{}.tfrecord.zz".format(output_name)) | ||
|
||
preprocessing.write_tf_examples(fname, tf_examples) | ||
|
||
|
||
def gather( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,15 +161,15 @@ def get_input_tensors(batch_size, tf_records, num_repeats=None, | |
# End-to-end utility functions | ||
|
||
|
||
def make_dataset_from_selfplay(data_extracts, tf_record): | ||
def make_dataset_from_selfplay(data_extracts): | ||
''' | ||
Returns a set of tf.Examples. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return an iterable of tf.Example There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
Args: | ||
data_extracts: An iterable of (position, pi, result) tuples | ||
tf_record: name of file to write to | ||
''' | ||
tf_examples = (make_tf_example(features_lib.extract_features(pos), pi, result) | ||
for pos, pi, result in data_extracts) | ||
write_tf_examples(tf_record, tf_examples) | ||
return tf_examples | ||
|
||
|
||
def make_dataset_from_sgf(sgf_filename, tf_record): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
BASE_DIR = "gs://{}".format(BUCKET_NAME) | ||
MODELS_DIR = os.path.join(BASE_DIR, 'models') | ||
SELFPLAY_DIR = os.path.join(BASE_DIR, 'games') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we're rejiggering our folder naming scheme, can we rename the selfplay dir? "games" is pretty nondescriptive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
HOLDOUT_DIR = os.path.join(BASE_DIR, 'holdout') | ||
SGF_DIR = os.path.join(BASE_DIR, 'sgf') | ||
TRAINING_CHUNK_DIR = os.path.join(BASE_DIR, 'data', 'training_chunks') | ||
|
||
|
@@ -88,6 +89,7 @@ def selfplay(readouts=1600, verbose=2, resign_threshold=0.99): | |
main.selfplay( | ||
load_file=model_save_file, | ||
output_dir=os.path.join(SELFPLAY_DIR, model_name), | ||
holdout_dir=os.path.join(HOLDOUT_DIR, model_name), | ||
output_sgf=SGF_DIR, | ||
readouts=readouts, | ||
verbose=verbose, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this written to local disk?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's written to wherever you pass it. This can be a gs:// path