repo
stringlengths
7
54
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
20
28.4k
docstring
stringlengths
1
46.3k
docstring_tokens
listlengths
1
1.66k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
summary
stringlengths
4
350
obf_code
stringlengths
7.85k
764k
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
process_record_dataset
def process_record_dataset(dataset, is_training, batch_size, shuffle_buffer, parse_record_fn, num_epochs=1, num_gpus=None, examples_per_epoch=None, dtype=tf.float32): """Given a Dataset with raw records, return an iterator over the records. Args: dataset: A...
python
def process_record_dataset(dataset, is_training, batch_size, shuffle_buffer, parse_record_fn, num_epochs=1, num_gpus=None, examples_per_epoch=None, dtype=tf.float32): """Given a Dataset with raw records, return an iterator over the records. Args: dataset: A...
[ "def", "process_record_dataset", "(", "dataset", ",", "is_training", ",", "batch_size", ",", "shuffle_buffer", ",", "parse_record_fn", ",", "num_epochs", "=", "1", ",", "num_gpus", "=", "None", ",", "examples_per_epoch", "=", "None", ",", "dtype", "=", "tf", "...
Given a Dataset with raw records, return an iterator over the records. Args: dataset: A Dataset representing raw records is_training: A boolean denoting whether the input is for training. batch_size: The number of samples per batch. shuffle_buffer: The buffer size to use when shuffling records. A lar...
[ "Given", "a", "Dataset", "with", "raw", "records", "return", "an", "iterator", "over", "the", "records", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L46-L99
train
This function takes a Dataset representing raw records and returns an iterator over the records.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
get_synth_input_fn
def get_synth_input_fn(height, width, num_channels, num_classes): """Returns an input function that returns a dataset with zeroes. This is useful in debugging input pipeline performance, as it removes all elements of file reading and image preprocessing. Args: height: Integer height that will be used to c...
python
def get_synth_input_fn(height, width, num_channels, num_classes): """Returns an input function that returns a dataset with zeroes. This is useful in debugging input pipeline performance, as it removes all elements of file reading and image preprocessing. Args: height: Integer height that will be used to c...
[ "def", "get_synth_input_fn", "(", "height", ",", "width", ",", "num_channels", ",", "num_classes", ")", ":", "def", "input_fn", "(", "is_training", ",", "data_dir", ",", "batch_size", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=un...
Returns an input function that returns a dataset with zeroes. This is useful in debugging input pipeline performance, as it removes all elements of file reading and image preprocessing. Args: height: Integer height that will be used to create a fake image tensor. width: Integer width that will be used t...
[ "Returns", "an", "input", "function", "that", "returns", "a", "dataset", "with", "zeroes", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L102-L124
train
Returns an input function that returns a dataset with zeroes.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
learning_rate_with_decay
def learning_rate_with_decay( batch_size, batch_denom, num_images, boundary_epochs, decay_rates, base_lr=0.1, enable_lars=False): """Get a learning rate that decays step-wise as training progresses. Args: batch_size: the number of examples processed in each training batch. batch_denom: this value w...
python
def learning_rate_with_decay( batch_size, batch_denom, num_images, boundary_epochs, decay_rates, base_lr=0.1, enable_lars=False): """Get a learning rate that decays step-wise as training progresses. Args: batch_size: the number of examples processed in each training batch. batch_denom: this value w...
[ "def", "learning_rate_with_decay", "(", "batch_size", ",", "batch_denom", ",", "num_images", ",", "boundary_epochs", ",", "decay_rates", ",", "base_lr", "=", "0.1", ",", "enable_lars", "=", "False", ")", ":", "initial_learning_rate", "=", "base_lr", "*", "batch_si...
Get a learning rate that decays step-wise as training progresses. Args: batch_size: the number of examples processed in each training batch. batch_denom: this value will be used to scale the base learning rate. `0.1 * batch size` is divided by this number, such that when batch_denom == batch_size...
[ "Get", "a", "learning", "rate", "that", "decays", "step", "-", "wise", "as", "training", "progresses", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L130-L218
train
Returns a function that decays step - wise as training progresses.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
resnet_model_fn
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE, label_smoothing=0.0, enable_lars=False)...
python
def resnet_model_fn(features, labels, mode, model_class, resnet_size, weight_decay, learning_rate_fn, momentum, data_format, version, loss_scale, loss_filter_fn=None, dtype=resnet_model.DEFAULT_DTYPE, label_smoothing=0.0, enable_lars=False)...
[ "def", "resnet_model_fn", "(", "features", ",", "labels", ",", "mode", ",", "model_class", ",", "resnet_size", ",", "weight_decay", ",", "learning_rate_fn", ",", "momentum", ",", "data_format", ",", "version", ",", "loss_scale", ",", "loss_filter_fn", "=", "None...
Shared functionality for different resnet model_fns. Initializes the ResnetModel representing the model layers and uses that model to build the necessary EstimatorSpecs for the `mode` in question. For training, this means building losses, the optimizer, and the train op that get passed into the EstimatorSpec. ...
[ "Shared", "functionality", "for", "different", "resnet", "model_fns", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L221-L402
train
Private function for different ResNet model_fns.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
per_device_batch_size
def per_device_batch_size(batch_size, num_gpus): """For multi-gpu, batch-size must be a multiple of the number of GPUs. Note that this should eventually be handled by DistributionStrategies directly. Multi-GPU support is currently experimental, however, so doing the work here until that feature is in place. ...
python
def per_device_batch_size(batch_size, num_gpus): """For multi-gpu, batch-size must be a multiple of the number of GPUs. Note that this should eventually be handled by DistributionStrategies directly. Multi-GPU support is currently experimental, however, so doing the work here until that feature is in place. ...
[ "def", "per_device_batch_size", "(", "batch_size", ",", "num_gpus", ")", ":", "if", "num_gpus", "<=", "1", ":", "return", "batch_size", "remainder", "=", "batch_size", "%", "num_gpus", "if", "remainder", ":", "err", "=", "(", "'When running with multiple GPUs, bat...
For multi-gpu, batch-size must be a multiple of the number of GPUs. Note that this should eventually be handled by DistributionStrategies directly. Multi-GPU support is currently experimental, however, so doing the work here until that feature is in place. Args: batch_size: Global batch size to be divided...
[ "For", "multi", "-", "gpu", "batch", "-", "size", "must", "be", "a", "multiple", "of", "the", "number", "of", "GPUs", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L405-L433
train
Returns the batch size per device.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_run_loop.py
resnet_main
def resnet_main(seed, flags, model_function, input_function, shape=None): """Shared main loop for ResNet Models. Args: flags: FLAGS object that contains the params for running. See ResnetArgParser for created flags. model_function: the function that instantiates the Model and builds the ops for...
python
def resnet_main(seed, flags, model_function, input_function, shape=None): """Shared main loop for ResNet Models. Args: flags: FLAGS object that contains the params for running. See ResnetArgParser for created flags. model_function: the function that instantiates the Model and builds the ops for...
[ "def", "resnet_main", "(", "seed", ",", "flags", ",", "model_function", ",", "input_function", ",", "shape", "=", "None", ")", ":", "mlperf_log", ".", "resnet_print", "(", "key", "=", "mlperf_log", ".", "RUN_START", ")", "# Using the Winograd non-fused algorithms ...
Shared main loop for ResNet Models. Args: flags: FLAGS object that contains the params for running. See ResnetArgParser for created flags. model_function: the function that instantiates the Model and builds the ops for train/eval. This will be passed directly into the estimator. input_functio...
[ "Shared", "main", "loop", "for", "ResNet", "Models", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_run_loop.py#L436-L589
train
Main function for ResNet Model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/ratings/ratings.py
compute_ratings
def compute_ratings(data=None): """ Returns the tuples of (model_id, rating, sigma) N.B. that `model_id` here is NOT the model number in the run 'data' is tuples of (winner, loser) model_ids (not model numbers) """ if data is None: with sqlite3.connect("ratings.db") as db: data ...
python
def compute_ratings(data=None): """ Returns the tuples of (model_id, rating, sigma) N.B. that `model_id` here is NOT the model number in the run 'data' is tuples of (winner, loser) model_ids (not model numbers) """ if data is None: with sqlite3.connect("ratings.db") as db: data ...
[ "def", "compute_ratings", "(", "data", "=", "None", ")", ":", "if", "data", "is", "None", ":", "with", "sqlite3", ".", "connect", "(", "\"ratings.db\"", ")", "as", "db", ":", "data", "=", "db", ".", "execute", "(", "\"select model_winner, model_loser from wi...
Returns the tuples of (model_id, rating, sigma) N.B. that `model_id` here is NOT the model number in the run 'data' is tuples of (winner, loser) model_ids (not model numbers)
[ "Returns", "the", "tuples", "of", "(", "model_id", "rating", "sigma", ")", "N", ".", "B", ".", "that", "model_id", "here", "is", "NOT", "the", "model", "number", "in", "the", "run" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/ratings/ratings.py#L165-L208
train
Computes the ratings for the current run of the current language.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/ratings/ratings.py
suggest_pairs
def suggest_pairs(top_n=10, per_n=3, ignore_before=300): """ Find the maximally interesting pairs of players to match up First, sort the ratings by uncertainty. Then, take the ten highest players with the highest uncertainty For each of them, call them `p1` Sort all the models by their distance from...
python
def suggest_pairs(top_n=10, per_n=3, ignore_before=300): """ Find the maximally interesting pairs of players to match up First, sort the ratings by uncertainty. Then, take the ten highest players with the highest uncertainty For each of them, call them `p1` Sort all the models by their distance from...
[ "def", "suggest_pairs", "(", "top_n", "=", "10", ",", "per_n", "=", "3", ",", "ignore_before", "=", "300", ")", ":", "db", "=", "sqlite3", ".", "connect", "(", "\"ratings.db\"", ")", "data", "=", "db", ".", "execute", "(", "\"select model_winner, model_los...
Find the maximally interesting pairs of players to match up First, sort the ratings by uncertainty. Then, take the ten highest players with the highest uncertainty For each of them, call them `p1` Sort all the models by their distance from p1's rating and take the 20 nearest rated models. ('candidat...
[ "Find", "the", "maximally", "interesting", "pairs", "of", "players", "to", "match", "up", "First", "sort", "the", "ratings", "by", "uncertainty", ".", "Then", "take", "the", "ten", "highest", "players", "with", "the", "highest", "uncertainty", "For", "each", ...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/ratings/ratings.py#L233-L268
train
Suggests the best pairs of players to match up
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/strategies.py
time_recommendation
def time_recommendation(move_num, seconds_per_move=5, time_limit=15 * 60, decay_factor=0.98): """Given the current move number and the 'desired' seconds per move, return how much time should actually be used. This is intended specifically for CGOS time controls, which has an absolute...
python
def time_recommendation(move_num, seconds_per_move=5, time_limit=15 * 60, decay_factor=0.98): """Given the current move number and the 'desired' seconds per move, return how much time should actually be used. This is intended specifically for CGOS time controls, which has an absolute...
[ "def", "time_recommendation", "(", "move_num", ",", "seconds_per_move", "=", "5", ",", "time_limit", "=", "15", "*", "60", ",", "decay_factor", "=", "0.98", ")", ":", "# Divide by two since you only play half the moves in a game.", "player_move_num", "=", "move_num", ...
Given the current move number and the 'desired' seconds per move, return how much time should actually be used. This is intended specifically for CGOS time controls, which has an absolute 15-minute time limit. The strategy is to spend the maximum possible moves using seconds_per_move, and then switch t...
[ "Given", "the", "current", "move", "number", "and", "the", "desired", "seconds", "per", "move", "return", "how", "much", "time", "should", "actually", "be", "used", ".", "This", "is", "intended", "specifically", "for", "CGOS", "time", "controls", "which", "h...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/strategies.py#L54-L80
train
This function returns how much time should actually be used for a particular move number and the desired seconds per move.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/strategies.py
MCTSPlayer.suggest_move
def suggest_move(self, position): """Used for playing a single game. For parallel play, use initialize_move, select_leaf, incorporate_results, and pick_move """ start = time.time() if self.timed_match: while time.time() - start < self.seconds_per_move: ...
python
def suggest_move(self, position): """Used for playing a single game. For parallel play, use initialize_move, select_leaf, incorporate_results, and pick_move """ start = time.time() if self.timed_match: while time.time() - start < self.seconds_per_move: ...
[ "def", "suggest_move", "(", "self", ",", "position", ")", ":", "start", "=", "time", ".", "time", "(", ")", "if", "self", ".", "timed_match", ":", "while", "time", ".", "time", "(", ")", "-", "start", "<", "self", ".", "seconds_per_move", ":", "self"...
Used for playing a single game. For parallel play, use initialize_move, select_leaf, incorporate_results, and pick_move
[ "Used", "for", "playing", "a", "single", "game", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/strategies.py#L123-L149
train
Suggests a move based on the current position.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/strategies.py
MCTSPlayer.play_move
def play_move(self, c): """Notable side effects: - finalizes the probability distribution according to this roots visit counts into the class' running tally, `searches_pi` - Makes the node associated with this move the root, for future `inject_noise` calls. """ ...
python
def play_move(self, c): """Notable side effects: - finalizes the probability distribution according to this roots visit counts into the class' running tally, `searches_pi` - Makes the node associated with this move the root, for future `inject_noise` calls. """ ...
[ "def", "play_move", "(", "self", ",", "c", ")", ":", "if", "not", "self", ".", "two_player_mode", ":", "self", ".", "searches_pi", ".", "append", "(", "self", ".", "root", ".", "children_as_pi", "(", "self", ".", "root", ".", "position", ".", "n", "<...
Notable side effects: - finalizes the probability distribution according to this roots visit counts into the class' running tally, `searches_pi` - Makes the node associated with this move the root, for future `inject_noise` calls.
[ "Notable", "side", "effects", ":", "-", "finalizes", "the", "probability", "distribution", "according", "to", "this", "roots", "visit", "counts", "into", "the", "class", "running", "tally", "searches_pi", "-", "Makes", "the", "node", "associated", "with", "this"...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/strategies.py#L151-L173
train
Plays the move.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/strategies.py
MCTSPlayer.pick_move
def pick_move(self): """Picks a move to play, based on MCTS readout statistics. Highest N is most robust indicator. In the early stage of the game, pick a move weighted by visit count; later on, pick the absolute max.""" if self.root.position.n >= self.temp_threshold: fcoord...
python
def pick_move(self): """Picks a move to play, based on MCTS readout statistics. Highest N is most robust indicator. In the early stage of the game, pick a move weighted by visit count; later on, pick the absolute max.""" if self.root.position.n >= self.temp_threshold: fcoord...
[ "def", "pick_move", "(", "self", ")", ":", "if", "self", ".", "root", ".", "position", ".", "n", ">=", "self", ".", "temp_threshold", ":", "fcoord", "=", "self", ".", "root", ".", "best_child", "(", ")", "else", ":", "cdf", "=", "self", ".", "root"...
Picks a move to play, based on MCTS readout statistics. Highest N is most robust indicator. In the early stage of the game, pick a move weighted by visit count; later on, pick the absolute max.
[ "Picks", "a", "move", "to", "play", "based", "on", "MCTS", "readout", "statistics", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/strategies.py#L175-L188
train
Picks a move to play based on MCTS readout statistics.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/models/decoder.py
RecurrentAttention.forward
def forward(self, inputs, hidden, context, context_len): """ Execute RecurrentAttention. :param inputs: tensor with inputs :param hidden: hidden state for LSTM layer :param context: context tensor from encoder :param context_len: vector of encoder sequence lengths ...
python
def forward(self, inputs, hidden, context, context_len): """ Execute RecurrentAttention. :param inputs: tensor with inputs :param hidden: hidden state for LSTM layer :param context: context tensor from encoder :param context_len: vector of encoder sequence lengths ...
[ "def", "forward", "(", "self", ",", "inputs", ",", "hidden", ",", "context", ",", "context_len", ")", ":", "# set attention mask, sequences have different lengths, this mask", "# allows to include only valid elements of context in attention's", "# softmax", "self", ".", "attn",...
Execute RecurrentAttention. :param inputs: tensor with inputs :param hidden: hidden state for LSTM layer :param context: context tensor from encoder :param context_len: vector of encoder sequence lengths :returns (rnn_outputs, hidden, attn_output, attn_scores)
[ "Execute", "RecurrentAttention", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/models/decoder.py#L42-L62
train
Execute RecurrentAttention.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/models/decoder.py
ResidualRecurrentDecoder.init_hidden
def init_hidden(self, hidden): """ Converts flattened hidden state (from sequence generator) into a tuple of hidden states. :param hidden: None or flattened hidden state for decoder RNN layers """ if hidden is not None: # per-layer chunks hidden =...
python
def init_hidden(self, hidden): """ Converts flattened hidden state (from sequence generator) into a tuple of hidden states. :param hidden: None or flattened hidden state for decoder RNN layers """ if hidden is not None: # per-layer chunks hidden =...
[ "def", "init_hidden", "(", "self", ",", "hidden", ")", ":", "if", "hidden", "is", "not", "None", ":", "# per-layer chunks", "hidden", "=", "hidden", ".", "chunk", "(", "self", ".", "num_layers", ")", "# (h, c) chunks for LSTM layer", "hidden", "=", "tuple", ...
Converts flattened hidden state (from sequence generator) into a tuple of hidden states. :param hidden: None or flattened hidden state for decoder RNN layers
[ "Converts", "flattened", "hidden", "state", "(", "from", "sequence", "generator", ")", "into", "a", "tuple", "of", "hidden", "states", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/models/decoder.py#L149-L165
train
Converts flattened hidden state into a tuple
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/models/decoder.py
ResidualRecurrentDecoder.package_hidden
def package_hidden(self): """ Flattens the hidden state from all LSTM layers into one tensor (for the sequence generator). """ if self.inference: hidden = torch.cat(tuple(itertools.chain(*self.next_hidden))) else: hidden = None return hidde...
python
def package_hidden(self): """ Flattens the hidden state from all LSTM layers into one tensor (for the sequence generator). """ if self.inference: hidden = torch.cat(tuple(itertools.chain(*self.next_hidden))) else: hidden = None return hidde...
[ "def", "package_hidden", "(", "self", ")", ":", "if", "self", ".", "inference", ":", "hidden", "=", "torch", ".", "cat", "(", "tuple", "(", "itertools", ".", "chain", "(", "*", "self", ".", "next_hidden", ")", ")", ")", "else", ":", "hidden", "=", ...
Flattens the hidden state from all LSTM layers into one tensor (for the sequence generator).
[ "Flattens", "the", "hidden", "state", "from", "all", "LSTM", "layers", "into", "one", "tensor", "(", "for", "the", "sequence", "generator", ")", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/models/decoder.py#L176-L185
train
Flattens the hidden state from all LSTM layers into one tensor.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/models/decoder.py
ResidualRecurrentDecoder.forward
def forward(self, inputs, context, inference=False): """ Execute the decoder. :param inputs: tensor with inputs to the decoder :param context: state of encoder, encoder sequence lengths and hidden state of decoder's LSTM layers :param inference: if True stores and re...
python
def forward(self, inputs, context, inference=False): """ Execute the decoder. :param inputs: tensor with inputs to the decoder :param context: state of encoder, encoder sequence lengths and hidden state of decoder's LSTM layers :param inference: if True stores and re...
[ "def", "forward", "(", "self", ",", "inputs", ",", "context", ",", "inference", "=", "False", ")", ":", "self", ".", "inference", "=", "inference", "enc_context", ",", "enc_len", ",", "hidden", "=", "context", "hidden", "=", "self", ".", "init_hidden", "...
Execute the decoder. :param inputs: tensor with inputs to the decoder :param context: state of encoder, encoder sequence lengths and hidden state of decoder's LSTM layers :param inference: if True stores and repackages hidden state
[ "Execute", "the", "decoder", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/models/decoder.py#L187-L222
train
Execute the decoder.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
compliance/mlperf_compliance/tf_mlperf_log.py
log_deferred
def log_deferred(op, log_id, every_n=1, first_n=None): """Helper method inserting compliance logging ops. Note: This helper is not guaranteed to be efficient, as it will insert ops and control dependencies. If this proves to be a bottleneck, submitters may wish to consider other methods such as ext...
python
def log_deferred(op, log_id, every_n=1, first_n=None): """Helper method inserting compliance logging ops. Note: This helper is not guaranteed to be efficient, as it will insert ops and control dependencies. If this proves to be a bottleneck, submitters may wish to consider other methods such as ext...
[ "def", "log_deferred", "(", "op", ",", "log_id", ",", "every_n", "=", "1", ",", "first_n", "=", "None", ")", ":", "prefix", "=", "\":::MLPv0.5.0 [{}]\"", ".", "format", "(", "log_id", ")", "if", "not", "first_n", "is", "not", "None", "and", "first_n", ...
Helper method inserting compliance logging ops. Note: This helper is not guaranteed to be efficient, as it will insert ops and control dependencies. If this proves to be a bottleneck, submitters may wish to consider other methods such as extracting values from an .events file. Args: op...
[ "Helper", "method", "inserting", "compliance", "logging", "ops", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/compliance/mlperf_compliance/tf_mlperf_log.py#L33-L62
train
Helper method for logging a single operation in a new context.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/utils/model_zoo.py
cache_url
def cache_url(url, model_dir=None, progress=True): r"""Loads the Torch serialized object at the given URL. If the object is already present in `model_dir`, it's deserialized and returned. The filename part of the URL should follow the naming convention ``filename-<sha256>.ext`` where ``<sha256>`` is the...
python
def cache_url(url, model_dir=None, progress=True): r"""Loads the Torch serialized object at the given URL. If the object is already present in `model_dir`, it's deserialized and returned. The filename part of the URL should follow the naming convention ``filename-<sha256>.ext`` where ``<sha256>`` is the...
[ "def", "cache_url", "(", "url", ",", "model_dir", "=", "None", ",", "progress", "=", "True", ")", ":", "if", "model_dir", "is", "None", ":", "torch_home", "=", "os", ".", "path", ".", "expanduser", "(", "os", ".", "getenv", "(", "'TORCH_HOME'", ",", ...
r"""Loads the Torch serialized object at the given URL. If the object is already present in `model_dir`, it's deserialized and returned. The filename part of the URL should follow the naming convention ``filename-<sha256>.ext`` where ``<sha256>`` is the first eight or more digits of the SHA256 hash of t...
[ "r", "Loads", "the", "Torch", "serialized", "object", "at", "the", "given", "URL", ".", "If", "the", "object", "is", "already", "present", "in", "model_dir", "it", "s", "deserialized", "and", "returned", ".", "The", "filename", "part", "of", "the", "URL", ...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/utils/model_zoo.py#L15-L56
train
r Loads the Torch serialized object at the given URL and saves it in the given model_dir.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/attention_layer.py
Attention.split_heads
def split_heads(self, x): """Split x into different heads, and transpose the resulting value. The tensor is transposed to insure the inner dimensions hold the correct values during the matrix multiplication. Args: x: A tensor with shape [batch_size, length, hidden_size] Returns: A ten...
python
def split_heads(self, x): """Split x into different heads, and transpose the resulting value. The tensor is transposed to insure the inner dimensions hold the correct values during the matrix multiplication. Args: x: A tensor with shape [batch_size, length, hidden_size] Returns: A ten...
[ "def", "split_heads", "(", "self", ",", "x", ")", ":", "with", "tf", ".", "name_scope", "(", "\"split_heads\"", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "x", ")", "[", "0", "]", "length", "=", "tf", ".", "shape", "(", "x", ")", "[", ...
Split x into different heads, and transpose the resulting value. The tensor is transposed to insure the inner dimensions hold the correct values during the matrix multiplication. Args: x: A tensor with shape [batch_size, length, hidden_size] Returns: A tensor with shape [batch_size, num_h...
[ "Split", "x", "into", "different", "heads", "and", "transpose", "the", "resulting", "value", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/attention_layer.py#L56-L79
train
Splits x into different heads and transpose the resulting value.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/attention_layer.py
Attention.combine_heads
def combine_heads(self, x): """Combine tensor that has been split. Args: x: A tensor [batch_size, num_heads, length, hidden_size/num_heads] Returns: A tensor with shape [batch_size, length, hidden_size] """ with tf.name_scope("combine_heads"): batch_size = tf.shape(x)[0] le...
python
def combine_heads(self, x): """Combine tensor that has been split. Args: x: A tensor [batch_size, num_heads, length, hidden_size/num_heads] Returns: A tensor with shape [batch_size, length, hidden_size] """ with tf.name_scope("combine_heads"): batch_size = tf.shape(x)[0] le...
[ "def", "combine_heads", "(", "self", ",", "x", ")", ":", "with", "tf", ".", "name_scope", "(", "\"combine_heads\"", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "x", ")", "[", "0", "]", "length", "=", "tf", ".", "shape", "(", "x", ")", "...
Combine tensor that has been split. Args: x: A tensor [batch_size, num_heads, length, hidden_size/num_heads] Returns: A tensor with shape [batch_size, length, hidden_size]
[ "Combine", "tensor", "that", "has", "been", "split", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/attention_layer.py#L81-L94
train
Combine tensor that has been split.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/attention_layer.py
Attention.call
def call(self, x, y, bias, cache=None): """Apply attention mechanism to x and y. Args: x: a tensor with shape [batch_size, length_x, hidden_size] y: a tensor with shape [batch_size, length_y, hidden_size] bias: attention bias that will be added to the result of the dot product. cache: (...
python
def call(self, x, y, bias, cache=None): """Apply attention mechanism to x and y. Args: x: a tensor with shape [batch_size, length_x, hidden_size] y: a tensor with shape [batch_size, length_y, hidden_size] bias: attention bias that will be added to the result of the dot product. cache: (...
[ "def", "call", "(", "self", ",", "x", ",", "y", ",", "bias", ",", "cache", "=", "None", ")", ":", "# Linearly project the query (q), key (k) and value (v) using different", "# learned projections. This is in preparation of splitting them into", "# multiple heads. Multi-head atten...
Apply attention mechanism to x and y. Args: x: a tensor with shape [batch_size, length_x, hidden_size] y: a tensor with shape [batch_size, length_y, hidden_size] bias: attention bias that will be added to the result of the dot product. cache: (Used during prediction) dictionary with tensors...
[ "Apply", "attention", "mechanism", "to", "x", "and", "y", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/attention_layer.py#L96-L154
train
Apply attention mechanism to x and y.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_save_vocab_file
def _save_vocab_file(vocab_file, subtoken_list): """Save subtokens to file.""" with tf.gfile.Open(vocab_file, mode="w") as f: for subtoken in subtoken_list: f.write("'%s'\n" % _unicode_to_native(subtoken))
python
def _save_vocab_file(vocab_file, subtoken_list): """Save subtokens to file.""" with tf.gfile.Open(vocab_file, mode="w") as f: for subtoken in subtoken_list: f.write("'%s'\n" % _unicode_to_native(subtoken))
[ "def", "_save_vocab_file", "(", "vocab_file", ",", "subtoken_list", ")", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "vocab_file", ",", "mode", "=", "\"w\"", ")", "as", "f", ":", "for", "subtoken", "in", "subtoken_list", ":", "f", ".", "write", ...
Save subtokens to file.
[ "Save", "subtokens", "to", "file", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L185-L189
train
Save subtokens to file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_load_vocab_file
def _load_vocab_file(vocab_file, reserved_tokens=None): """Load vocabulary while ensuring reserved tokens are at the top.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS subtoken_list = [] with tf.gfile.Open(vocab_file, mode="r") as f: for line in f: subtoken = _native_to_unicode...
python
def _load_vocab_file(vocab_file, reserved_tokens=None): """Load vocabulary while ensuring reserved tokens are at the top.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS subtoken_list = [] with tf.gfile.Open(vocab_file, mode="r") as f: for line in f: subtoken = _native_to_unicode...
[ "def", "_load_vocab_file", "(", "vocab_file", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":", "reserved_tokens", "=", "RESERVED_TOKENS", "subtoken_list", "=", "[", "]", "with", "tf", ".", "gfile", ".", "Open", "(", ...
Load vocabulary while ensuring reserved tokens are at the top.
[ "Load", "vocabulary", "while", "ensuring", "reserved", "tokens", "are", "at", "the", "top", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L192-L205
train
Load vocabulary while ensuring reserved tokens are at the top.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_native_to_unicode
def _native_to_unicode(s): """Convert string to unicode (required in Python 2).""" if six.PY2: return s if isinstance(s, unicode) else s.decode("utf-8") else: return s
python
def _native_to_unicode(s): """Convert string to unicode (required in Python 2).""" if six.PY2: return s if isinstance(s, unicode) else s.decode("utf-8") else: return s
[ "def", "_native_to_unicode", "(", "s", ")", ":", "if", "six", ".", "PY2", ":", "return", "s", "if", "isinstance", "(", "s", ",", "unicode", ")", "else", "s", ".", "decode", "(", "\"utf-8\"", ")", "else", ":", "return", "s" ]
Convert string to unicode (required in Python 2).
[ "Convert", "string", "to", "unicode", "(", "required", "in", "Python", "2", ")", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L208-L213
train
Convert string to unicode.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_unicode_to_native
def _unicode_to_native(s): """Convert string from unicode to native format (required in Python 2).""" if six.PY2: return s.encode("utf-8") if isinstance(s, unicode) else s else: return s
python
def _unicode_to_native(s): """Convert string from unicode to native format (required in Python 2).""" if six.PY2: return s.encode("utf-8") if isinstance(s, unicode) else s else: return s
[ "def", "_unicode_to_native", "(", "s", ")", ":", "if", "six", ".", "PY2", ":", "return", "s", ".", "encode", "(", "\"utf-8\"", ")", "if", "isinstance", "(", "s", ",", "unicode", ")", "else", "s", "else", ":", "return", "s" ]
Convert string from unicode to native format (required in Python 2).
[ "Convert", "string", "from", "unicode", "to", "native", "format", "(", "required", "in", "Python", "2", ")", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L216-L221
train
Convert string from unicode to native format
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_split_string_to_tokens
def _split_string_to_tokens(text): """Splits text to a list of string tokens.""" if not text: return [] ret = [] token_start = 0 # Classify each character in the input string is_alnum = [c in _ALPHANUMERIC_CHAR_SET for c in text] for pos in xrange(1, len(text)): if is_alnum[pos] != is_alnum[pos - ...
python
def _split_string_to_tokens(text): """Splits text to a list of string tokens.""" if not text: return [] ret = [] token_start = 0 # Classify each character in the input string is_alnum = [c in _ALPHANUMERIC_CHAR_SET for c in text] for pos in xrange(1, len(text)): if is_alnum[pos] != is_alnum[pos - ...
[ "def", "_split_string_to_tokens", "(", "text", ")", ":", "if", "not", "text", ":", "return", "[", "]", "ret", "=", "[", "]", "token_start", "=", "0", "# Classify each character in the input string", "is_alnum", "=", "[", "c", "in", "_ALPHANUMERIC_CHAR_SET", "for...
Splits text to a list of string tokens.
[ "Splits", "text", "to", "a", "list", "of", "string", "tokens", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L224-L240
train
Splits text to a list of string tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_escape_token
def _escape_token(token, alphabet): r"""Replace characters that aren't in the alphabet and append "_" to token. Apply three transformations to the token: 1. Replace underline character "_" with "\u", and backslash "\" with "\\". 2. Replace characters outside of the alphabet with "\###;", where ### is the ...
python
def _escape_token(token, alphabet): r"""Replace characters that aren't in the alphabet and append "_" to token. Apply three transformations to the token: 1. Replace underline character "_" with "\u", and backslash "\" with "\\". 2. Replace characters outside of the alphabet with "\###;", where ### is the ...
[ "def", "_escape_token", "(", "token", ",", "alphabet", ")", ":", "token", "=", "token", ".", "replace", "(", "u\"\\\\\"", ",", "u\"\\\\\\\\\"", ")", ".", "replace", "(", "u\"_\"", ",", "u\"\\\\u\"", ")", "ret", "=", "[", "c", "if", "c", "in", "alphabet...
r"""Replace characters that aren't in the alphabet and append "_" to token. Apply three transformations to the token: 1. Replace underline character "_" with "\u", and backslash "\" with "\\". 2. Replace characters outside of the alphabet with "\###;", where ### is the character's Unicode code point. ...
[ "r", "Replace", "characters", "that", "aren", "t", "in", "the", "alphabet", "and", "append", "_", "to", "token", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L254-L272
train
Escapes a token in the alphabet and appends _ to the token.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_unescape_token
def _unescape_token(token): r"""Replaces escaped characters in the token with their unescaped versions. Applies inverse transformations as _escape_token(): 1. Replace "\u" with "_", and "\\" with "\". 2. Replace "\###;" with the unicode character the ### refers to. Args: token: escaped string Ret...
python
def _unescape_token(token): r"""Replaces escaped characters in the token with their unescaped versions. Applies inverse transformations as _escape_token(): 1. Replace "\u" with "_", and "\\" with "\". 2. Replace "\###;" with the unicode character the ### refers to. Args: token: escaped string Ret...
[ "def", "_unescape_token", "(", "token", ")", ":", "def", "match", "(", "m", ")", ":", "r\"\"\"Returns replacement string for matched object.\n\n Matched objects contain one of the strings that matches the regex pattern:\n r\"\\\\u|\\\\\\\\|\\\\([0-9]+);\"\n The strings can be '\\u...
r"""Replaces escaped characters in the token with their unescaped versions. Applies inverse transformations as _escape_token(): 1. Replace "\u" with "_", and "\\" with "\". 2. Replace "\###;" with the unicode character the ### refers to. Args: token: escaped string Returns: unescaped string
[ "r", "Replaces", "escaped", "characters", "in", "the", "token", "with", "their", "unescaped", "versions", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L275-L327
train
r Replaces escaped characters in the token with their unescaped versions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_count_tokens
def _count_tokens(files, file_byte_limit=1e6): """Return token counts of words in the files. Samples file_byte_limit bytes from each file, and counts the words that appear in the samples. The samples are semi-evenly distributed across the file. Args: files: List of filepaths file_byte_limit: Max numbe...
python
def _count_tokens(files, file_byte_limit=1e6): """Return token counts of words in the files. Samples file_byte_limit bytes from each file, and counts the words that appear in the samples. The samples are semi-evenly distributed across the file. Args: files: List of filepaths file_byte_limit: Max numbe...
[ "def", "_count_tokens", "(", "files", ",", "file_byte_limit", "=", "1e6", ")", ":", "token_counts", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "filepath", "in", "files", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "filepath", ...
Return token counts of words in the files. Samples file_byte_limit bytes from each file, and counts the words that appear in the samples. The samples are semi-evenly distributed across the file. Args: files: List of filepaths file_byte_limit: Max number of bytes that will be read from each file. Retu...
[ "Return", "token", "counts", "of", "words", "in", "the", "files", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L330-L364
train
Return the number of words in the file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_split_token_to_subtokens
def _split_token_to_subtokens(token, subtoken_dict, max_subtoken_length): """Splits a token into subtokens defined in the subtoken dict.""" ret = [] start = 0 token_len = len(token) while start < token_len: # Find the longest subtoken, so iterate backwards. for end in xrange(min(token_len, start + max...
python
def _split_token_to_subtokens(token, subtoken_dict, max_subtoken_length): """Splits a token into subtokens defined in the subtoken dict.""" ret = [] start = 0 token_len = len(token) while start < token_len: # Find the longest subtoken, so iterate backwards. for end in xrange(min(token_len, start + max...
[ "def", "_split_token_to_subtokens", "(", "token", ",", "subtoken_dict", ",", "max_subtoken_length", ")", ":", "ret", "=", "[", "]", "start", "=", "0", "token_len", "=", "len", "(", "token", ")", "while", "start", "<", "token_len", ":", "# Find the longest subt...
Splits a token into subtokens defined in the subtoken dict.
[ "Splits", "a", "token", "into", "subtokens", "defined", "in", "the", "subtoken", "dict", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L372-L391
train
Splits a token into subtokens defined in the subtoken dict.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_generate_subtokens_with_target_vocab_size
def _generate_subtokens_with_target_vocab_size( token_counts, alphabet, target_size, threshold, min_count=None, reserved_tokens=None): """Generate subtoken vocabulary close to the target size.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS if min_count is not None: tf.logging.in...
python
def _generate_subtokens_with_target_vocab_size( token_counts, alphabet, target_size, threshold, min_count=None, reserved_tokens=None): """Generate subtoken vocabulary close to the target size.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS if min_count is not None: tf.logging.in...
[ "def", "_generate_subtokens_with_target_vocab_size", "(", "token_counts", ",", "alphabet", ",", "target_size", ",", "threshold", ",", "min_count", "=", "None", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":", "reserved_token...
Generate subtoken vocabulary close to the target size.
[ "Generate", "subtoken", "vocabulary", "close", "to", "the", "target", "size", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L394-L435
train
Generate subtoken vocabulary with target size.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_generate_alphabet_dict
def _generate_alphabet_dict(iterable, reserved_tokens=None): """Create set of characters that appear in any element in the iterable.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS alphabet = {c for token in iterable for c in token} alphabet |= {c for token in reserved_tokens for c in token...
python
def _generate_alphabet_dict(iterable, reserved_tokens=None): """Create set of characters that appear in any element in the iterable.""" if reserved_tokens is None: reserved_tokens = RESERVED_TOKENS alphabet = {c for token in iterable for c in token} alphabet |= {c for token in reserved_tokens for c in token...
[ "def", "_generate_alphabet_dict", "(", "iterable", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":", "reserved_tokens", "=", "RESERVED_TOKENS", "alphabet", "=", "{", "c", "for", "token", "in", "iterable", "for", "c", "i...
Create set of characters that appear in any element in the iterable.
[ "Create", "set", "of", "characters", "that", "appear", "in", "any", "element", "in", "the", "iterable", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L438-L445
train
Create set of characters that appear in any element in the iterable.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_count_and_gen_subtokens
def _count_and_gen_subtokens( token_counts, alphabet, subtoken_dict, max_subtoken_length): """Count number of times subtokens appear, and generate new subtokens. Args: token_counts: dict mapping tokens to the number of times they appear in the original files. alphabet: list of allowed characters....
python
def _count_and_gen_subtokens( token_counts, alphabet, subtoken_dict, max_subtoken_length): """Count number of times subtokens appear, and generate new subtokens. Args: token_counts: dict mapping tokens to the number of times they appear in the original files. alphabet: list of allowed characters....
[ "def", "_count_and_gen_subtokens", "(", "token_counts", ",", "alphabet", ",", "subtoken_dict", ",", "max_subtoken_length", ")", ":", "subtoken_counts", "=", "collections", ".", "defaultdict", "(", "int", ")", "for", "token", ",", "count", "in", "six", ".", "iter...
Count number of times subtokens appear, and generate new subtokens. Args: token_counts: dict mapping tokens to the number of times they appear in the original files. alphabet: list of allowed characters. Used to escape the tokens, which guarantees that all tokens can be split into subtokens. ...
[ "Count", "number", "of", "times", "subtokens", "appear", "and", "generate", "new", "subtokens", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L448-L478
train
Count number of times subtokens appear and generate new subtokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_filter_and_bucket_subtokens
def _filter_and_bucket_subtokens(subtoken_counts, min_count): """Return a bucketed list of subtokens that are filtered by count. Args: subtoken_counts: defaultdict mapping subtokens to their counts min_count: int count used to filter subtokens Returns: List of subtoken sets, where subtokens in set i...
python
def _filter_and_bucket_subtokens(subtoken_counts, min_count): """Return a bucketed list of subtokens that are filtered by count. Args: subtoken_counts: defaultdict mapping subtokens to their counts min_count: int count used to filter subtokens Returns: List of subtoken sets, where subtokens in set i...
[ "def", "_filter_and_bucket_subtokens", "(", "subtoken_counts", ",", "min_count", ")", ":", "# Create list of buckets, where subtokens in bucket i have length i.", "subtoken_buckets", "=", "[", "]", "for", "subtoken", ",", "count", "in", "six", ".", "iteritems", "(", "subt...
Return a bucketed list of subtokens that are filtered by count. Args: subtoken_counts: defaultdict mapping subtokens to their counts min_count: int count used to filter subtokens Returns: List of subtoken sets, where subtokens in set i have the same length=i.
[ "Return", "a", "bucketed", "list", "of", "subtokens", "that", "are", "filtered", "by", "count", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L481-L499
train
Return a list of subtokens that are filtered by count.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_gen_new_subtoken_list
def _gen_new_subtoken_list( subtoken_counts, min_count, alphabet, reserved_tokens=None): """Generate candidate subtokens ordered by count, and new max subtoken length. Add subtokens to the candiate list in order of length (longest subtokens first). When a subtoken is added, the counts of each of its prefixes...
python
def _gen_new_subtoken_list( subtoken_counts, min_count, alphabet, reserved_tokens=None): """Generate candidate subtokens ordered by count, and new max subtoken length. Add subtokens to the candiate list in order of length (longest subtokens first). When a subtoken is added, the counts of each of its prefixes...
[ "def", "_gen_new_subtoken_list", "(", "subtoken_counts", ",", "min_count", ",", "alphabet", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":", "reserved_tokens", "=", "RESERVED_TOKENS", "# Create a list of (count, subtoken) for each...
Generate candidate subtokens ordered by count, and new max subtoken length. Add subtokens to the candiate list in order of length (longest subtokens first). When a subtoken is added, the counts of each of its prefixes are decreased. Prefixes that don't appear much outside the subtoken are not added to the cand...
[ "Generate", "candidate", "subtokens", "ordered", "by", "count", "and", "new", "max", "subtoken", "length", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L502-L571
train
Generate a new list of candidate subtokens ordered by count and new max subtoken length.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
_generate_subtokens
def _generate_subtokens( token_counts, alphabet, min_count, num_iterations=4, reserved_tokens=None): """Create a list of subtokens in decreasing order of frequency. Args: token_counts: dict mapping str tokens -> int count alphabet: set of characters min_count: int minimum number of times a subt...
python
def _generate_subtokens( token_counts, alphabet, min_count, num_iterations=4, reserved_tokens=None): """Create a list of subtokens in decreasing order of frequency. Args: token_counts: dict mapping str tokens -> int count alphabet: set of characters min_count: int minimum number of times a subt...
[ "def", "_generate_subtokens", "(", "token_counts", ",", "alphabet", ",", "min_count", ",", "num_iterations", "=", "4", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":", "reserved_tokens", "=", "RESERVED_TOKENS", "# Use alph...
Create a list of subtokens in decreasing order of frequency. Args: token_counts: dict mapping str tokens -> int count alphabet: set of characters min_count: int minimum number of times a subtoken must appear before it is added to the vocabulary. num_iterations: int number of iterations to gener...
[ "Create", "a", "list", "of", "subtokens", "in", "decreasing", "order", "of", "frequency", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L574-L616
train
Generate a list of subtokens in decreasing order of frequency.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
Subtokenizer.init_from_files
def init_from_files( vocab_file, files, target_vocab_size, threshold, min_count=None, file_byte_limit=1e6, reserved_tokens=None): """Create subtoken vocabulary based on files, and save vocab to file. Args: vocab_file: String name of vocab file to store subtoken vocabulary. files: List o...
python
def init_from_files( vocab_file, files, target_vocab_size, threshold, min_count=None, file_byte_limit=1e6, reserved_tokens=None): """Create subtoken vocabulary based on files, and save vocab to file. Args: vocab_file: String name of vocab file to store subtoken vocabulary. files: List o...
[ "def", "init_from_files", "(", "vocab_file", ",", "files", ",", "target_vocab_size", ",", "threshold", ",", "min_count", "=", "None", ",", "file_byte_limit", "=", "1e6", ",", "reserved_tokens", "=", "None", ")", ":", "if", "reserved_tokens", "is", "None", ":",...
Create subtoken vocabulary based on files, and save vocab to file. Args: vocab_file: String name of vocab file to store subtoken vocabulary. files: List of file paths that will be used to generate vocabulary. target_vocab_size: target vocabulary size to generate. threshold: int threshold of...
[ "Create", "subtoken", "vocabulary", "based", "on", "files", "and", "save", "vocab", "to", "file", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L87-L126
train
Create a subtoken vocabulary from a list of files.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
Subtokenizer.encode
def encode(self, raw_string, add_eos=False): """Encodes a string into a list of int subtoken ids.""" ret = [] tokens = _split_string_to_tokens(_native_to_unicode(raw_string)) for token in tokens: ret.extend(self._token_to_subtoken_ids(token)) if add_eos: ret.append(EOS_ID) return ret
python
def encode(self, raw_string, add_eos=False): """Encodes a string into a list of int subtoken ids.""" ret = [] tokens = _split_string_to_tokens(_native_to_unicode(raw_string)) for token in tokens: ret.extend(self._token_to_subtoken_ids(token)) if add_eos: ret.append(EOS_ID) return ret
[ "def", "encode", "(", "self", ",", "raw_string", ",", "add_eos", "=", "False", ")", ":", "ret", "=", "[", "]", "tokens", "=", "_split_string_to_tokens", "(", "_native_to_unicode", "(", "raw_string", ")", ")", "for", "token", "in", "tokens", ":", "ret", "...
Encodes a string into a list of int subtoken ids.
[ "Encodes", "a", "string", "into", "a", "list", "of", "int", "subtoken", "ids", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L128-L136
train
Encodes a string into a list of int subtoken ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
Subtokenizer._token_to_subtoken_ids
def _token_to_subtoken_ids(self, token): """Encode a single token into a list of subtoken ids.""" cache_location = hash(token) % self._cache_size cache_key, cache_value = self._cache[cache_location] if cache_key == token: return cache_value ret = _split_token_to_subtokens( _escape_tok...
python
def _token_to_subtoken_ids(self, token): """Encode a single token into a list of subtoken ids.""" cache_location = hash(token) % self._cache_size cache_key, cache_value = self._cache[cache_location] if cache_key == token: return cache_value ret = _split_token_to_subtokens( _escape_tok...
[ "def", "_token_to_subtoken_ids", "(", "self", ",", "token", ")", ":", "cache_location", "=", "hash", "(", "token", ")", "%", "self", ".", "_cache_size", "cache_key", ",", "cache_value", "=", "self", ".", "_cache", "[", "cache_location", "]", "if", "cache_key...
Encode a single token into a list of subtoken ids.
[ "Encode", "a", "single", "token", "into", "a", "list", "of", "subtoken", "ids", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L138-L151
train
Encode a single token into a list of subtoken ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
Subtokenizer.decode
def decode(self, subtokens): """Converts list of int subtokens ids into a string.""" if isinstance(subtokens, np.ndarray): # Note that list(subtokens) converts subtokens to a python list, but the # items remain as np.int32. This converts both the array and its items. subtokens = subtokens.toli...
python
def decode(self, subtokens): """Converts list of int subtokens ids into a string.""" if isinstance(subtokens, np.ndarray): # Note that list(subtokens) converts subtokens to a python list, but the # items remain as np.int32. This converts both the array and its items. subtokens = subtokens.toli...
[ "def", "decode", "(", "self", ",", "subtokens", ")", ":", "if", "isinstance", "(", "subtokens", ",", "np", ".", "ndarray", ")", ":", "# Note that list(subtokens) converts subtokens to a python list, but the", "# items remain as np.int32. This converts both the array and its ite...
Converts list of int subtokens ids into a string.
[ "Converts", "list", "of", "int", "subtokens", "ids", "into", "a", "string", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L153-L167
train
Converts list of int subtokens ids into a string.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/utils/tokenizer.py
Subtokenizer._subtoken_ids_to_tokens
def _subtoken_ids_to_tokens(self, subtokens): """Convert list of int subtoken ids to a list of string tokens.""" escaped_tokens = "".join([ self.subtoken_list[s] for s in subtokens if s < len(self.subtoken_list)]) escaped_tokens = escaped_tokens.split("_") # All tokens in the vocabulary...
python
def _subtoken_ids_to_tokens(self, subtokens): """Convert list of int subtoken ids to a list of string tokens.""" escaped_tokens = "".join([ self.subtoken_list[s] for s in subtokens if s < len(self.subtoken_list)]) escaped_tokens = escaped_tokens.split("_") # All tokens in the vocabulary...
[ "def", "_subtoken_ids_to_tokens", "(", "self", ",", "subtokens", ")", ":", "escaped_tokens", "=", "\"\"", ".", "join", "(", "[", "self", ".", "subtoken_list", "[", "s", "]", "for", "s", "in", "subtokens", "if", "s", "<", "len", "(", "self", ".", "subto...
Convert list of int subtoken ids to a list of string tokens.
[ "Convert", "list", "of", "int", "subtoken", "ids", "to", "a", "list", "of", "string", "tokens", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/utils/tokenizer.py#L169-L182
train
Convert list of int subtoken ids to list of string tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/oneoffs/training_curve.py
batch_run_many
def batch_run_many(player, positions, batch_size=100): """Used to avoid a memory oveflow issue when running the network on too many positions. TODO: This should be a member function of player.network?""" prob_list = [] value_list = [] for idx in range(0, len(positions), batch_size): prob...
python
def batch_run_many(player, positions, batch_size=100): """Used to avoid a memory oveflow issue when running the network on too many positions. TODO: This should be a member function of player.network?""" prob_list = [] value_list = [] for idx in range(0, len(positions), batch_size): prob...
[ "def", "batch_run_many", "(", "player", ",", "positions", ",", "batch_size", "=", "100", ")", ":", "prob_list", "=", "[", "]", "value_list", "=", "[", "]", "for", "idx", "in", "range", "(", "0", ",", "len", "(", "positions", ")", ",", "batch_size", "...
Used to avoid a memory oveflow issue when running the network on too many positions. TODO: This should be a member function of player.network?
[ "Used", "to", "avoid", "a", "memory", "oveflow", "issue", "when", "running", "the", "network", "on", "too", "many", "positions", ".", "TODO", ":", "This", "should", "be", "a", "member", "function", "of", "player", ".", "network?" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/oneoffs/training_curve.py#L62-L72
train
Runs the network on a batch of positions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py
MaskPostProcessor.forward
def forward(self, x, boxes): """ Arguments: x (Tensor): the mask logits boxes (list[BoxList]): bounding boxes that are used as reference, one for ech image Returns: results (list[BoxList]): one BoxList for each image, containing ...
python
def forward(self, x, boxes): """ Arguments: x (Tensor): the mask logits boxes (list[BoxList]): bounding boxes that are used as reference, one for ech image Returns: results (list[BoxList]): one BoxList for each image, containing ...
[ "def", "forward", "(", "self", ",", "x", ",", "boxes", ")", ":", "mask_prob", "=", "x", ".", "sigmoid", "(", ")", "# select masks coresponding to the predicted classes", "num_masks", "=", "x", ".", "shape", "[", "0", "]", "labels", "=", "[", "bbox", ".", ...
Arguments: x (Tensor): the mask logits boxes (list[BoxList]): bounding boxes that are used as reference, one for ech image Returns: results (list[BoxList]): one BoxList for each image, containing the extra field mask
[ "Arguments", ":", "x", "(", "Tensor", ")", ":", "the", "mask", "logits", "boxes", "(", "list", "[", "BoxList", "]", ")", ":", "bounding", "boxes", "that", "are", "used", "as", "reference", "one", "for", "ech", "image" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/modeling/roi_heads/mask_head/inference.py#L27-L61
train
Forward computation of the mask logits.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
compliance/mlperf_compliance/mlperf_log.py
get_caller
def get_caller(stack_index=2, root_dir=None): ''' Returns file.py:lineno of your caller. A stack_index of 2 will provide the caller of the function calling this function. Notice that stack_index of 2 or more will fail if called from global scope. ''' caller = inspect.getframeinfo(inspect.stack()[stack_i...
python
def get_caller(stack_index=2, root_dir=None): ''' Returns file.py:lineno of your caller. A stack_index of 2 will provide the caller of the function calling this function. Notice that stack_index of 2 or more will fail if called from global scope. ''' caller = inspect.getframeinfo(inspect.stack()[stack_i...
[ "def", "get_caller", "(", "stack_index", "=", "2", ",", "root_dir", "=", "None", ")", ":", "caller", "=", "inspect", ".", "getframeinfo", "(", "inspect", ".", "stack", "(", ")", "[", "stack_index", "]", "[", "0", "]", ")", "# Trim the filenames for readabi...
Returns file.py:lineno of your caller. A stack_index of 2 will provide the caller of the function calling this function. Notice that stack_index of 2 or more will fail if called from global scope.
[ "Returns", "file", ".", "py", ":", "lineno", "of", "your", "caller", ".", "A", "stack_index", "of", "2", "will", "provide", "the", "caller", "of", "the", "function", "calling", "this", "function", ".", "Notice", "that", "stack_index", "of", "2", "or", "m...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/compliance/mlperf_compliance/mlperf_log.py#L67-L77
train
Returns file. py : lineno of your caller.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
compliance/mlperf_compliance/mlperf_log.py
_mlperf_print
def _mlperf_print(key, value=None, benchmark=None, stack_offset=0, tag_set=None, deferred=False, root_dir=None, extra_print=False, prefix=""): ''' Prints out an MLPerf Log Line. key: The MLPerf log key such as 'CLOCK' or 'QUALITY'. See the list of log keys in the spec. value: ...
python
def _mlperf_print(key, value=None, benchmark=None, stack_offset=0, tag_set=None, deferred=False, root_dir=None, extra_print=False, prefix=""): ''' Prints out an MLPerf Log Line. key: The MLPerf log key such as 'CLOCK' or 'QUALITY'. See the list of log keys in the spec. value: ...
[ "def", "_mlperf_print", "(", "key", ",", "value", "=", "None", ",", "benchmark", "=", "None", ",", "stack_offset", "=", "0", ",", "tag_set", "=", "None", ",", "deferred", "=", "False", ",", "root_dir", "=", "None", ",", "extra_print", "=", "False", ","...
Prints out an MLPerf Log Line. key: The MLPerf log key such as 'CLOCK' or 'QUALITY'. See the list of log keys in the spec. value: The value which contains no newlines. benchmark: The short code for the benchmark being run, see the MLPerf log spec. stack_offset: Increase the value to go deeper into the stack to...
[ "Prints", "out", "an", "MLPerf", "Log", "Line", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/compliance/mlperf_compliance/mlperf_log.py#L80-L138
train
Print an MLPerf log line.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/rl_loop/shipname.py
generate
def generate(model_num): """Generates a new model name, given the model number.""" if model_num == 0: new_name = 'bootstrap' else: new_name = random.choice(NAMES) full_name = "%06d-%s" % (model_num, new_name) return full_name
python
def generate(model_num): """Generates a new model name, given the model number.""" if model_num == 0: new_name = 'bootstrap' else: new_name = random.choice(NAMES) full_name = "%06d-%s" % (model_num, new_name) return full_name
[ "def", "generate", "(", "model_num", ")", ":", "if", "model_num", "==", "0", ":", "new_name", "=", "'bootstrap'", "else", ":", "new_name", "=", "random", ".", "choice", "(", "NAMES", ")", "full_name", "=", "\"%06d-%s\"", "%", "(", "model_num", ",", "new_...
Generates a new model name, given the model number.
[ "Generates", "a", "new", "model", "name", "given", "the", "model", "number", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/rl_loop/shipname.py#L27-L34
train
Generates a new model name given the model number.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/rl_loop/shipname.py
detect_model_num
def detect_model_num(string): """Takes a string related to a model name and extract its model number. For example: '000000-bootstrap.index' => 0 """ match = re.match(MODEL_NUM_REGEX, string) if match: return int(match.group()) return None
python
def detect_model_num(string): """Takes a string related to a model name and extract its model number. For example: '000000-bootstrap.index' => 0 """ match = re.match(MODEL_NUM_REGEX, string) if match: return int(match.group()) return None
[ "def", "detect_model_num", "(", "string", ")", ":", "match", "=", "re", ".", "match", "(", "MODEL_NUM_REGEX", ",", "string", ")", "if", "match", ":", "return", "int", "(", "match", ".", "group", "(", ")", ")", "return", "None" ]
Takes a string related to a model name and extract its model number. For example: '000000-bootstrap.index' => 0
[ "Takes", "a", "string", "related", "to", "a", "model", "name", "and", "extract", "its", "model", "number", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/rl_loop/shipname.py#L37-L46
train
Takes a string related to a model name and extract its model number.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/rl_loop/shipname.py
detect_model_name
def detect_model_name(string): """Takes a string related to a model name and extract its model name. For example: '000000-bootstrap.index' => '000000-bootstrap' """ match = re.match(MODEL_NAME_REGEX, string) if match: return match.group() return None
python
def detect_model_name(string): """Takes a string related to a model name and extract its model name. For example: '000000-bootstrap.index' => '000000-bootstrap' """ match = re.match(MODEL_NAME_REGEX, string) if match: return match.group() return None
[ "def", "detect_model_name", "(", "string", ")", ":", "match", "=", "re", ".", "match", "(", "MODEL_NAME_REGEX", ",", "string", ")", "if", "match", ":", "return", "match", ".", "group", "(", ")", "return", "None" ]
Takes a string related to a model name and extract its model name. For example: '000000-bootstrap.index' => '000000-bootstrap'
[ "Takes", "a", "string", "related", "to", "a", "model", "name", "and", "extract", "its", "model", "name", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/rl_loop/shipname.py#L49-L58
train
Takes a string related to a model name and extract its model name.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
batch_norm
def batch_norm(inputs, training, data_format): """Performs a batch normalization using a standard set of parameters.""" # We set fused=True for a significant performance boost. See # https://www.tensorflow.org/performance/performance_guide#common_fused_ops outputs = tf.layers.batch_normalization( inputs=i...
python
def batch_norm(inputs, training, data_format): """Performs a batch normalization using a standard set of parameters.""" # We set fused=True for a significant performance boost. See # https://www.tensorflow.org/performance/performance_guide#common_fused_ops outputs = tf.layers.batch_normalization( inputs=i...
[ "def", "batch_norm", "(", "inputs", ",", "training", ",", "data_format", ")", ":", "# We set fused=True for a significant performance boost. See", "# https://www.tensorflow.org/performance/performance_guide#common_fused_ops", "outputs", "=", "tf", ".", "layers", ".", "batch_norma...
Performs a batch normalization using a standard set of parameters.
[ "Performs", "a", "batch", "normalization", "using", "a", "standard", "set", "of", "parameters", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L51-L64
train
Performs a batch normalization using a standard set of parameters.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
fixed_padding
def fixed_padding(inputs, kernel_size, data_format): """Pads the input along the spatial dimensions independently of input size. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_format. kernel_size: The kernel to be used...
python
def fixed_padding(inputs, kernel_size, data_format): """Pads the input along the spatial dimensions independently of input size. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_format. kernel_size: The kernel to be used...
[ "def", "fixed_padding", "(", "inputs", ",", "kernel_size", ",", "data_format", ")", ":", "pad_total", "=", "kernel_size", "-", "1", "pad_beg", "=", "pad_total", "//", "2", "pad_end", "=", "pad_total", "-", "pad_beg", "if", "data_format", "==", "'channels_first...
Pads the input along the spatial dimensions independently of input size. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_format. kernel_size: The kernel to be used in the conv2d or max_pool2d operation. S...
[ "Pads", "the", "input", "along", "the", "spatial", "dimensions", "independently", "of", "input", "size", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L67-L91
train
Pads the input along the spatial dimensions independently of input size.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
conv2d_fixed_padding
def conv2d_fixed_padding(inputs, filters, kernel_size, strides, data_format): """Strided 2-D convolution with explicit padding.""" # The padding is consistent and is based only on `kernel_size`, not on the # dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone). inputs_for_logging = inputs if...
python
def conv2d_fixed_padding(inputs, filters, kernel_size, strides, data_format): """Strided 2-D convolution with explicit padding.""" # The padding is consistent and is based only on `kernel_size`, not on the # dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone). inputs_for_logging = inputs if...
[ "def", "conv2d_fixed_padding", "(", "inputs", ",", "filters", ",", "kernel_size", ",", "strides", ",", "data_format", ")", ":", "# The padding is consistent and is based only on `kernel_size`, not on the", "# dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone).", "i...
Strided 2-D convolution with explicit padding.
[ "Strided", "2", "-", "D", "convolution", "with", "explicit", "padding", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L94-L114
train
Strided 2 - D convolution with explicit padding.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
_bottleneck_block_v1
def _bottleneck_block_v1(inputs, filters, training, projection_shortcut, strides, data_format): """A single block for ResNet v1, with a bottleneck. Similar to _building_block_v1(), except using the "bottleneck" blocks described in: Convolution then batch normalization then ReLU as de...
python
def _bottleneck_block_v1(inputs, filters, training, projection_shortcut, strides, data_format): """A single block for ResNet v1, with a bottleneck. Similar to _building_block_v1(), except using the "bottleneck" blocks described in: Convolution then batch normalization then ReLU as de...
[ "def", "_bottleneck_block_v1", "(", "inputs", ",", "filters", ",", "training", ",", "projection_shortcut", ",", "strides", ",", "data_format", ")", ":", "resnet_log_helper", ".", "log_begin_block", "(", "input_tensor", "=", "inputs", ",", "block_type", "=", "mlper...
A single block for ResNet v1, with a bottleneck. Similar to _building_block_v1(), except using the "bottleneck" blocks described in: Convolution then batch normalization then ReLU as described by: Deep Residual Learning for Image Recognition https://arxiv.org/pdf/1512.03385.pdf by Kaiming He,...
[ "A", "single", "block", "for", "ResNet", "v1", "with", "a", "bottleneck", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L130-L196
train
Builds a bottleneck block for ResNet v1.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
block_layer
def block_layer(inputs, filters, bottleneck, block_fn, blocks, strides, training, name, data_format): """Creates one layer of blocks for the ResNet model. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_form...
python
def block_layer(inputs, filters, bottleneck, block_fn, blocks, strides, training, name, data_format): """Creates one layer of blocks for the ResNet model. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_form...
[ "def", "block_layer", "(", "inputs", ",", "filters", ",", "bottleneck", ",", "block_fn", ",", "blocks", ",", "strides", ",", "training", ",", "name", ",", "data_format", ")", ":", "# Bottleneck blocks end with 4x the number of filters as they start with", "filters_out",...
Creates one layer of blocks for the ResNet model. Args: inputs: A tensor of size [batch, channels, height_in, width_in] or [batch, height_in, width_in, channels] depending on data_format. filters: The number of filters for the first convolution of the layer. bottleneck: Is the block created a bottl...
[ "Creates", "one", "layer", "of", "blocks", "for", "the", "ResNet", "model", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L204-L242
train
Creates a block layer for the ResNet model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
image_classification/tensorflow/official/resnet/resnet_model.py
Model._custom_dtype_getter
def _custom_dtype_getter(self, getter, name, shape=None, dtype=DEFAULT_DTYPE, *args, **kwargs): """Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has...
python
def _custom_dtype_getter(self, getter, name, shape=None, dtype=DEFAULT_DTYPE, *args, **kwargs): """Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has...
[ "def", "_custom_dtype_getter", "(", "self", ",", "getter", ",", "name", ",", "shape", "=", "None", ",", "dtype", "=", "DEFAULT_DTYPE", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "dtype", "in", "CASTABLE_TYPES", ":", "var", "=", "getter"...
Creates variables in fp32, then casts to fp16 if necessary. This function is a custom getter. A custom getter is a function with the same signature as tf.get_variable, except it has an additional getter parameter. Custom getters can be passed as the `custom_getter` parameter of tf.variable_scope. Then,...
[ "Creates", "variables", "in", "fp32", "then", "casts", "to", "fp16", "if", "necessary", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/resnet_model.py#L328-L367
train
Custom dtype getter for the base class
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/data/sampler.py
DistributedSampler.init_rng
def init_rng(self): """ Creates new RNG, seed depends on current epoch idx. """ rng = torch.Generator() seed = self.seeds[self.epoch] logging.info(f'Sampler for epoch {self.epoch} uses seed {seed}') rng.manual_seed(seed) return rng
python
def init_rng(self): """ Creates new RNG, seed depends on current epoch idx. """ rng = torch.Generator() seed = self.seeds[self.epoch] logging.info(f'Sampler for epoch {self.epoch} uses seed {seed}') rng.manual_seed(seed) return rng
[ "def", "init_rng", "(", "self", ")", ":", "rng", "=", "torch", ".", "Generator", "(", ")", "seed", "=", "self", ".", "seeds", "[", "self", ".", "epoch", "]", "logging", ".", "info", "(", "f'Sampler for epoch {self.epoch} uses seed {seed}'", ")", "rng", "."...
Creates new RNG, seed depends on current epoch idx.
[ "Creates", "new", "RNG", "seed", "depends", "on", "current", "epoch", "idx", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/data/sampler.py#L42-L50
train
Creates a new RNG with the current seed depends on current epoch idx.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/data/sampler.py
DistributedSampler.distribute_batches
def distribute_batches(self, indices): """ Assigns batches to workers. Consecutive ranks are getting consecutive batches. :param indices: torch.tensor with batch indices """ assert len(indices) == self.num_samples indices = indices.view(-1, self.batch_size) ...
python
def distribute_batches(self, indices): """ Assigns batches to workers. Consecutive ranks are getting consecutive batches. :param indices: torch.tensor with batch indices """ assert len(indices) == self.num_samples indices = indices.view(-1, self.batch_size) ...
[ "def", "distribute_batches", "(", "self", ",", "indices", ")", ":", "assert", "len", "(", "indices", ")", "==", "self", ".", "num_samples", "indices", "=", "indices", ".", "view", "(", "-", "1", ",", "self", ".", "batch_size", ")", "indices", "=", "ind...
Assigns batches to workers. Consecutive ranks are getting consecutive batches. :param indices: torch.tensor with batch indices
[ "Assigns", "batches", "to", "workers", ".", "Consecutive", "ranks", "are", "getting", "consecutive", "batches", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/data/sampler.py#L52-L67
train
Assign batches to workers.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/data/sampler.py
DistributedSampler.reshuffle_batches
def reshuffle_batches(self, indices, rng): """ Permutes global batches :param indices: torch.tensor with batch indices :param rng: instance of torch.Generator """ indices = indices.view(-1, self.global_batch_size) num_batches = indices.shape[0] order = to...
python
def reshuffle_batches(self, indices, rng): """ Permutes global batches :param indices: torch.tensor with batch indices :param rng: instance of torch.Generator """ indices = indices.view(-1, self.global_batch_size) num_batches = indices.shape[0] order = to...
[ "def", "reshuffle_batches", "(", "self", ",", "indices", ",", "rng", ")", ":", "indices", "=", "indices", ".", "view", "(", "-", "1", ",", "self", ".", "global_batch_size", ")", "num_batches", "=", "indices", ".", "shape", "[", "0", "]", "order", "=", ...
Permutes global batches :param indices: torch.tensor with batch indices :param rng: instance of torch.Generator
[ "Permutes", "global", "batches" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/data/sampler.py#L69-L81
train
Reshuffle the global batches.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/retinanet/retinanet.py
RetinaNetModule.forward
def forward(self, images, features, targets=None): """ Arguments: images (ImageList): images for which we want to compute the predictions features (list[Tensor]): features computed from the images that are used for computing the predictions. Each tensor in the lis...
python
def forward(self, images, features, targets=None): """ Arguments: images (ImageList): images for which we want to compute the predictions features (list[Tensor]): features computed from the images that are used for computing the predictions. Each tensor in the lis...
[ "def", "forward", "(", "self", ",", "images", ",", "features", ",", "targets", "=", "None", ")", ":", "box_cls", ",", "box_regression", "=", "self", ".", "head", "(", "features", ")", "anchors", "=", "self", ".", "anchor_generator", "(", "images", ",", ...
Arguments: images (ImageList): images for which we want to compute the predictions features (list[Tensor]): features computed from the images that are used for computing the predictions. Each tensor in the list correspond to different feature levels ta...
[ "Arguments", ":", "images", "(", "ImageList", ")", ":", "images", "for", "which", "we", "want", "to", "compute", "the", "predictions", "features", "(", "list", "[", "Tensor", "]", ")", ":", "features", "computed", "from", "the", "images", "that", "are", ...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/modeling/rpn/retinanet/retinanet.py#L113-L134
train
Forward computation of the next set of images and features.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/layers/smooth_l1_loss.py
smooth_l1_loss
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True): """ very similar to the smooth_l1_loss from pytorch, but with the extra beta parameter """ n = torch.abs(input - target) cond = n < beta loss = torch.where(cond, 0.5 * n ** 2 / beta, n - 0.5 * beta) if size_average: ...
python
def smooth_l1_loss(input, target, beta=1. / 9, size_average=True): """ very similar to the smooth_l1_loss from pytorch, but with the extra beta parameter """ n = torch.abs(input - target) cond = n < beta loss = torch.where(cond, 0.5 * n ** 2 / beta, n - 0.5 * beta) if size_average: ...
[ "def", "smooth_l1_loss", "(", "input", ",", "target", ",", "beta", "=", "1.", "/", "9", ",", "size_average", "=", "True", ")", ":", "n", "=", "torch", ".", "abs", "(", "input", "-", "target", ")", "cond", "=", "n", "<", "beta", "loss", "=", "torc...
very similar to the smooth_l1_loss from pytorch, but with the extra beta parameter
[ "very", "similar", "to", "the", "smooth_l1_loss", "from", "pytorch", "but", "with", "the", "extra", "beta", "parameter" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/layers/smooth_l1_loss.py#L6-L16
train
smooth_l1_loss is a function that takes input and target and returns the loss of the last n elements of the last n elements of the last n elements of the last n elements of the last n elements.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/oneoffs/heatmap.py
eval_policy
def eval_policy(eval_positions): """Evaluate all positions with all models save the policy heatmaps as CSVs CSV name is "heatmap-<position_name>-<model-index>.csv" CSV format is: model number, value network output, policy network outputs position_name is taken from the SGF file Policy network outp...
python
def eval_policy(eval_positions): """Evaluate all positions with all models save the policy heatmaps as CSVs CSV name is "heatmap-<position_name>-<model-index>.csv" CSV format is: model number, value network output, policy network outputs position_name is taken from the SGF file Policy network outp...
[ "def", "eval_policy", "(", "eval_positions", ")", ":", "model_paths", "=", "oneoff_utils", ".", "get_model_paths", "(", "fsdb", ".", "models_dir", "(", ")", ")", "idx_start", "=", "FLAGS", ".", "idx_start", "eval_every", "=", "FLAGS", ".", "eval_every", "print...
Evaluate all positions with all models save the policy heatmaps as CSVs CSV name is "heatmap-<position_name>-<model-index>.csv" CSV format is: model number, value network output, policy network outputs position_name is taken from the SGF file Policy network outputs (19x19) are saved in flat order (see...
[ "Evaluate", "all", "positions", "with", "all", "models", "save", "the", "policy", "heatmaps", "as", "CSVs" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/oneoffs/heatmap.py#L45-L85
train
Evaluate all positions with all models save the policy heatmaps as CSVs
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
dbg
def dbg(*objects, file=sys.stderr, flush=True, **kwargs): "Helper function to print to stderr and flush" print(*objects, file=file, flush=flush, **kwargs)
python
def dbg(*objects, file=sys.stderr, flush=True, **kwargs): "Helper function to print to stderr and flush" print(*objects, file=file, flush=flush, **kwargs)
[ "def", "dbg", "(", "*", "objects", ",", "file", "=", "sys", ".", "stderr", ",", "flush", "=", "True", ",", "*", "*", "kwargs", ")", ":", "print", "(", "*", "objects", ",", "file", "=", "file", ",", "flush", "=", "flush", ",", "*", "*", "kwargs"...
Helper function to print to stderr and flush
[ "Helper", "function", "to", "print", "to", "stderr", "and", "flush" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L27-L29
train
Helper function to print to stderr and flush
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
ensure_dir_exists
def ensure_dir_exists(directory): "Creates local directories if they don't exist." if directory.startswith('gs://'): return if not os.path.exists(directory): dbg("Making dir {}".format(directory)) os.makedirs(directory, exist_ok=True)
python
def ensure_dir_exists(directory): "Creates local directories if they don't exist." if directory.startswith('gs://'): return if not os.path.exists(directory): dbg("Making dir {}".format(directory)) os.makedirs(directory, exist_ok=True)
[ "def", "ensure_dir_exists", "(", "directory", ")", ":", "if", "directory", ".", "startswith", "(", "'gs://'", ")", ":", "return", "if", "not", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "dbg", "(", "\"Making dir {}\"", ".", "format", "...
Creates local directories if they don't exist.
[ "Creates", "local", "directories", "if", "they", "don", "t", "exist", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L32-L38
train
Creates local directories if they don t exist.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
parse_game_result
def parse_game_result(result): "Parse an SGF result string into value target." if re.match(r'[bB]\+', result): return 1 if re.match(r'[wW]\+', result): return -1 return 0
python
def parse_game_result(result): "Parse an SGF result string into value target." if re.match(r'[bB]\+', result): return 1 if re.match(r'[wW]\+', result): return -1 return 0
[ "def", "parse_game_result", "(", "result", ")", ":", "if", "re", ".", "match", "(", "r'[bB]\\+'", ",", "result", ")", ":", "return", "1", "if", "re", ".", "match", "(", "r'[wW]\\+'", ",", "result", ")", ":", "return", "-", "1", "return", "0" ]
Parse an SGF result string into value target.
[ "Parse", "an", "SGF", "result", "string", "into", "value", "target", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L41-L47
train
Parse an SGF result string into value target.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
iter_chunks
def iter_chunks(chunk_size, iterator): "Yield from an iterator in chunks of chunk_size." iterator = iter(iterator) while True: next_chunk = _take_n(chunk_size, iterator) # If len(iterable) % chunk_size == 0, don't return an empty chunk. if next_chunk: yield next_chunk ...
python
def iter_chunks(chunk_size, iterator): "Yield from an iterator in chunks of chunk_size." iterator = iter(iterator) while True: next_chunk = _take_n(chunk_size, iterator) # If len(iterable) % chunk_size == 0, don't return an empty chunk. if next_chunk: yield next_chunk ...
[ "def", "iter_chunks", "(", "chunk_size", ",", "iterator", ")", ":", "iterator", "=", "iter", "(", "iterator", ")", "while", "True", ":", "next_chunk", "=", "_take_n", "(", "chunk_size", ",", "iterator", ")", "# If len(iterable) % chunk_size == 0, don't return an emp...
Yield from an iterator in chunks of chunk_size.
[ "Yield", "from", "an", "iterator", "in", "chunks", "of", "chunk_size", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L59-L68
train
Yield from an iterator in chunks of chunk_size.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
timer
def timer(message): "Context manager for timing snippets of code." tick = time.time() yield tock = time.time() print("%s: %.3f seconds" % (message, (tock - tick)))
python
def timer(message): "Context manager for timing snippets of code." tick = time.time() yield tock = time.time() print("%s: %.3f seconds" % (message, (tock - tick)))
[ "def", "timer", "(", "message", ")", ":", "tick", "=", "time", ".", "time", "(", ")", "yield", "tock", "=", "time", ".", "time", "(", ")", "print", "(", "\"%s: %.3f seconds\"", "%", "(", "message", ",", "(", "tock", "-", "tick", ")", ")", ")" ]
Context manager for timing snippets of code.
[ "Context", "manager", "for", "timing", "snippets", "of", "code", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L72-L77
train
Context manager for timing snippets of code.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
reinforcement/tensorflow/minigo/utils.py
logged_timer
def logged_timer(message): "Context manager for timing snippets of code. Echos to logging module." tick = time.time() yield tock = time.time() logging.info("%s: %.3f seconds", message, (tock - tick))
python
def logged_timer(message): "Context manager for timing snippets of code. Echos to logging module." tick = time.time() yield tock = time.time() logging.info("%s: %.3f seconds", message, (tock - tick))
[ "def", "logged_timer", "(", "message", ")", ":", "tick", "=", "time", ".", "time", "(", ")", "yield", "tock", "=", "time", ".", "time", "(", ")", "logging", ".", "info", "(", "\"%s: %.3f seconds\"", ",", "message", ",", "(", "tock", "-", "tick", ")",...
Context manager for timing snippets of code. Echos to logging module.
[ "Context", "manager", "for", "timing", "snippets", "of", "code", ".", "Echos", "to", "logging", "module", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/reinforcement/tensorflow/minigo/utils.py#L81-L86
train
Context manager for timing snippets of code. Echos to logging module.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
find_file
def find_file(path, filename, max_depth=5): """Returns full filepath if the file is in path or a subdirectory.""" for root, dirs, files in os.walk(path): if filename in files: return os.path.join(root, filename) # Don't search past max_depth depth = root[len(path) + 1:].count(os.sep) if depth...
python
def find_file(path, filename, max_depth=5): """Returns full filepath if the file is in path or a subdirectory.""" for root, dirs, files in os.walk(path): if filename in files: return os.path.join(root, filename) # Don't search past max_depth depth = root[len(path) + 1:].count(os.sep) if depth...
[ "def", "find_file", "(", "path", ",", "filename", ",", "max_depth", "=", "5", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ")", ":", "if", "filename", "in", "files", ":", "return", "os", ".", "path", "...
Returns full filepath if the file is in path or a subdirectory.
[ "Returns", "full", "filepath", "if", "the", "file", "is", "in", "path", "or", "a", "subdirectory", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L86-L96
train
Finds a file in path or a subdirectory.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
get_raw_files
def get_raw_files(raw_dir, data_source): """Return raw files from source. Downloads/extracts if needed. Args: raw_dir: string directory to store raw files data_source: dictionary with {"url": url of compressed dataset containing input and target files "input": file with data in input language ...
python
def get_raw_files(raw_dir, data_source): """Return raw files from source. Downloads/extracts if needed. Args: raw_dir: string directory to store raw files data_source: dictionary with {"url": url of compressed dataset containing input and target files "input": file with data in input language ...
[ "def", "get_raw_files", "(", "raw_dir", ",", "data_source", ")", ":", "raw_files", "=", "{", "\"inputs\"", ":", "[", "]", ",", "\"targets\"", ":", "[", "]", ",", "}", "# keys", "for", "d", "in", "data_source", ":", "input_file", ",", "target_file", "=", ...
Return raw files from source. Downloads/extracts if needed. Args: raw_dir: string directory to store raw files data_source: dictionary with {"url": url of compressed dataset containing input and target files "input": file with data in input language "target": file with data in target lang...
[ "Return", "raw", "files", "from", "source", ".", "Downloads", "/", "extracts", "if", "needed", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L102-L127
train
Download and extract raw files from source.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
txt_line_iterator
def txt_line_iterator(path): """Iterate through lines of file.""" with tf.gfile.Open(path) as f: for line in f: yield line.strip()
python
def txt_line_iterator(path): """Iterate through lines of file.""" with tf.gfile.Open(path) as f: for line in f: yield line.strip()
[ "def", "txt_line_iterator", "(", "path", ")", ":", "with", "tf", ".", "gfile", ".", "Open", "(", "path", ")", "as", "f", ":", "for", "line", "in", "f", ":", "yield", "line", ".", "strip", "(", ")" ]
Iterate through lines of file.
[ "Iterate", "through", "lines", "of", "file", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L210-L214
train
Iterate through lines of file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
compile_files
def compile_files(raw_dir, raw_files, tag): """Compile raw files into a single file for each language. Args: raw_dir: Directory containing downloaded raw files. raw_files: Dict containing filenames of input and target data. {"inputs": list of files containing data in input language "targets": ...
python
def compile_files(raw_dir, raw_files, tag): """Compile raw files into a single file for each language. Args: raw_dir: Directory containing downloaded raw files. raw_files: Dict containing filenames of input and target data. {"inputs": list of files containing data in input language "targets": ...
[ "def", "compile_files", "(", "raw_dir", ",", "raw_files", ",", "tag", ")", ":", "tf", ".", "logging", ".", "info", "(", "\"Compiling files with tag %s.\"", "%", "tag", ")", "filename", "=", "\"%s-%s\"", "%", "(", "_PREFIX", ",", "tag", ")", "input_compiled_f...
Compile raw files into a single file for each language. Args: raw_dir: Directory containing downloaded raw files. raw_files: Dict containing filenames of input and target data. {"inputs": list of files containing data in input language "targets": list of files containing corresponding data in ta...
[ "Compile", "raw", "files", "into", "a", "single", "file", "for", "each", "language", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L217-L245
train
Compile raw files into a single file for each language.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
write_file
def write_file(writer, filename): """Write all of lines from file using the writer.""" for line in txt_line_iterator(filename): writer.write(line) writer.write("\n")
python
def write_file(writer, filename): """Write all of lines from file using the writer.""" for line in txt_line_iterator(filename): writer.write(line) writer.write("\n")
[ "def", "write_file", "(", "writer", ",", "filename", ")", ":", "for", "line", "in", "txt_line_iterator", "(", "filename", ")", ":", "writer", ".", "write", "(", "line", ")", "writer", ".", "write", "(", "\"\\n\"", ")" ]
Write all of lines from file using the writer.
[ "Write", "all", "of", "lines", "from", "file", "using", "the", "writer", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L248-L252
train
Write all of the lines from file using the writer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
encode_and_save_files
def encode_and_save_files( subtokenizer, data_dir, raw_files, tag, total_shards): """Save data from files as encoded Examples in TFrecord format. Args: subtokenizer: Subtokenizer object that will be used to encode the strings. data_dir: The directory in which to write the examples raw_files: A tupl...
python
def encode_and_save_files( subtokenizer, data_dir, raw_files, tag, total_shards): """Save data from files as encoded Examples in TFrecord format. Args: subtokenizer: Subtokenizer object that will be used to encode the strings. data_dir: The directory in which to write the examples raw_files: A tupl...
[ "def", "encode_and_save_files", "(", "subtokenizer", ",", "data_dir", ",", "raw_files", ",", "tag", ",", "total_shards", ")", ":", "# Create a file for each shard.", "filepaths", "=", "[", "shard_filename", "(", "data_dir", ",", "tag", ",", "n", "+", "1", ",", ...
Save data from files as encoded Examples in TFrecord format. Args: subtokenizer: Subtokenizer object that will be used to encode the strings. data_dir: The directory in which to write the examples raw_files: A tuple of (input, target) data files. Each line in the input and the corresponding line in...
[ "Save", "data", "from", "files", "as", "encoded", "Examples", "in", "TFrecord", "format", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L258-L305
train
Encode data from files as encoded Examples in TFrecord format.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
shard_filename
def shard_filename(path, tag, shard_num, total_shards): """Create filename for data shard.""" return os.path.join( path, "%s-%s-%s-%.5d-of-%.5d" % (_PREFIX, _ENCODE_TAG, tag, shard_num, total_shards))
python
def shard_filename(path, tag, shard_num, total_shards): """Create filename for data shard.""" return os.path.join( path, "%s-%s-%s-%.5d-of-%.5d" % (_PREFIX, _ENCODE_TAG, tag, shard_num, total_shards))
[ "def", "shard_filename", "(", "path", ",", "tag", ",", "shard_num", ",", "total_shards", ")", ":", "return", "os", ".", "path", ".", "join", "(", "path", ",", "\"%s-%s-%s-%.5d-of-%.5d\"", "%", "(", "_PREFIX", ",", "_ENCODE_TAG", ",", "tag", ",", "shard_num...
Create filename for data shard.
[ "Create", "filename", "for", "data", "shard", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L308-L311
train
Create filename for data shard.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
shuffle_records
def shuffle_records(fname): """Shuffle records in a single file.""" tf.logging.info("Shuffling records in file %s" % fname) # Rename file prior to shuffling tmp_fname = fname + ".unshuffled" tf.gfile.Rename(fname, tmp_fname) reader = tf.python_io.tf_record_iterator(tmp_fname) records = [] for record i...
python
def shuffle_records(fname): """Shuffle records in a single file.""" tf.logging.info("Shuffling records in file %s" % fname) # Rename file prior to shuffling tmp_fname = fname + ".unshuffled" tf.gfile.Rename(fname, tmp_fname) reader = tf.python_io.tf_record_iterator(tmp_fname) records = [] for record i...
[ "def", "shuffle_records", "(", "fname", ")", ":", "tf", ".", "logging", ".", "info", "(", "\"Shuffling records in file %s\"", "%", "fname", ")", "# Rename file prior to shuffling", "tmp_fname", "=", "fname", "+", "\".unshuffled\"", "tf", ".", "gfile", ".", "Rename...
Shuffle records in a single file.
[ "Shuffle", "records", "in", "a", "single", "file", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L314-L338
train
Shuffle records in a single file.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
dict_to_example
def dict_to_example(dictionary): """Converts a dictionary of string->int to a tf.Example.""" features = {} for k, v in six.iteritems(dictionary): features[k] = tf.train.Feature(int64_list=tf.train.Int64List(value=v)) return tf.train.Example(features=tf.train.Features(feature=features))
python
def dict_to_example(dictionary): """Converts a dictionary of string->int to a tf.Example.""" features = {} for k, v in six.iteritems(dictionary): features[k] = tf.train.Feature(int64_list=tf.train.Int64List(value=v)) return tf.train.Example(features=tf.train.Features(feature=features))
[ "def", "dict_to_example", "(", "dictionary", ")", ":", "features", "=", "{", "}", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "dictionary", ")", ":", "features", "[", "k", "]", "=", "tf", ".", "train", ".", "Feature", "(", "int64_list",...
Converts a dictionary of string->int to a tf.Example.
[ "Converts", "a", "dictionary", "of", "string", "-", ">", "int", "to", "a", "tf", ".", "Example", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L341-L346
train
Converts a dictionary of string - > int to a tf. Example.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
all_exist
def all_exist(filepaths): """Returns true if all files in the list exist.""" for fname in filepaths: if not tf.gfile.Exists(fname): return False return True
python
def all_exist(filepaths): """Returns true if all files in the list exist.""" for fname in filepaths: if not tf.gfile.Exists(fname): return False return True
[ "def", "all_exist", "(", "filepaths", ")", ":", "for", "fname", "in", "filepaths", ":", "if", "not", "tf", ".", "gfile", ".", "Exists", "(", "fname", ")", ":", "return", "False", "return", "True" ]
Returns true if all files in the list exist.
[ "Returns", "true", "if", "all", "files", "in", "the", "list", "exist", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L349-L354
train
Returns true if all files in the list exist.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/data_download.py
main
def main(unused_argv): """Obtain training and evaluation data for the Transformer model.""" tf.logging.set_verbosity(tf.logging.INFO) make_dir(FLAGS.raw_dir) make_dir(FLAGS.data_dir) # Get paths of download/extracted training and evaluation files. tf.logging.info("Step 1/4: Downloading data from source") ...
python
def main(unused_argv): """Obtain training and evaluation data for the Transformer model.""" tf.logging.set_verbosity(tf.logging.INFO) make_dir(FLAGS.raw_dir) make_dir(FLAGS.data_dir) # Get paths of download/extracted training and evaluation files. tf.logging.info("Step 1/4: Downloading data from source") ...
[ "def", "main", "(", "unused_argv", ")", ":", "tf", ".", "logging", ".", "set_verbosity", "(", "tf", ".", "logging", ".", "INFO", ")", "make_dir", "(", "FLAGS", ".", "raw_dir", ")", "make_dir", "(", "FLAGS", ".", "data_dir", ")", "# Get paths of download/ex...
Obtain training and evaluation data for the Transformer model.
[ "Obtain", "training", "and", "evaluation", "data", "for", "the", "Transformer", "model", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/data_download.py#L363-L397
train
Main function for the Transformer model.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/transformer.py
Transformer.encode
def encode(self, inputs, attention_bias): """Generate continuous representation for inputs. Args: inputs: int tensor with shape [batch_size, input_length]. attention_bias: float tensor with shape [batch_size, 1, 1, input_length] Returns: float tensor with shape [batch_size, input_length,...
python
def encode(self, inputs, attention_bias): """Generate continuous representation for inputs. Args: inputs: int tensor with shape [batch_size, input_length]. attention_bias: float tensor with shape [batch_size, 1, 1, input_length] Returns: float tensor with shape [batch_size, input_length,...
[ "def", "encode", "(", "self", ",", "inputs", ",", "attention_bias", ")", ":", "with", "tf", ".", "name_scope", "(", "\"encode\"", ")", ":", "# Prepare inputs to the layer stack by adding positional encodings and", "# applying dropout.", "embedded_inputs", "=", "self", "...
Generate continuous representation for inputs. Args: inputs: int tensor with shape [batch_size, input_length]. attention_bias: float tensor with shape [batch_size, 1, 1, input_length] Returns: float tensor with shape [batch_size, input_length, hidden_size]
[ "Generate", "continuous", "representation", "for", "inputs", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/transformer.py#L106-L135
train
Generates continuous representation of inputs.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/transformer.py
Transformer.decode
def decode(self, targets, encoder_outputs, attention_bias): """Generate logits for each value in the target sequence. Args: targets: target values for the output sequence. int tensor with shape [batch_size, target_length] encoder_outputs: continuous representation of input sequence. ...
python
def decode(self, targets, encoder_outputs, attention_bias): """Generate logits for each value in the target sequence. Args: targets: target values for the output sequence. int tensor with shape [batch_size, target_length] encoder_outputs: continuous representation of input sequence. ...
[ "def", "decode", "(", "self", ",", "targets", ",", "encoder_outputs", ",", "attention_bias", ")", ":", "with", "tf", ".", "name_scope", "(", "\"decode\"", ")", ":", "# Prepare inputs to decoder layers by shifting targets, adding positional", "# encoding and applying dropout...
Generate logits for each value in the target sequence. Args: targets: target values for the output sequence. int tensor with shape [batch_size, target_length] encoder_outputs: continuous representation of input sequence. float tensor with shape [batch_size, input_length, hidden_size] ...
[ "Generate", "logits", "for", "each", "value", "in", "the", "target", "sequence", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/transformer.py#L137-L176
train
Decode the target sequence.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/transformer.py
Transformer._get_symbols_to_logits_fn
def _get_symbols_to_logits_fn(self, max_decode_length): """Returns a decoding function that calculates logits of the next tokens.""" timing_signal = model_utils.get_position_encoding( max_decode_length + 1, self.params.hidden_size) decoder_self_attention_bias = model_utils.get_decoder_self_attentio...
python
def _get_symbols_to_logits_fn(self, max_decode_length): """Returns a decoding function that calculates logits of the next tokens.""" timing_signal = model_utils.get_position_encoding( max_decode_length + 1, self.params.hidden_size) decoder_self_attention_bias = model_utils.get_decoder_self_attentio...
[ "def", "_get_symbols_to_logits_fn", "(", "self", ",", "max_decode_length", ")", ":", "timing_signal", "=", "model_utils", ".", "get_position_encoding", "(", "max_decode_length", "+", "1", ",", "self", ".", "params", ".", "hidden_size", ")", "decoder_self_attention_bia...
Returns a decoding function that calculates logits of the next tokens.
[ "Returns", "a", "decoding", "function", "that", "calculates", "logits", "of", "the", "next", "tokens", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/transformer.py#L178-L215
train
Returns a decoding function that calculates logits of the next tokens.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/transformer.py
Transformer.predict
def predict(self, encoder_outputs, encoder_decoder_attention_bias): """Return predicted sequence.""" batch_size = tf.shape(encoder_outputs)[0] input_length = tf.shape(encoder_outputs)[1] max_decode_length = input_length + self.params.extra_decode_length symbols_to_logits_fn = self._get_symbols_to_l...
python
def predict(self, encoder_outputs, encoder_decoder_attention_bias): """Return predicted sequence.""" batch_size = tf.shape(encoder_outputs)[0] input_length = tf.shape(encoder_outputs)[1] max_decode_length = input_length + self.params.extra_decode_length symbols_to_logits_fn = self._get_symbols_to_l...
[ "def", "predict", "(", "self", ",", "encoder_outputs", ",", "encoder_decoder_attention_bias", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "encoder_outputs", ")", "[", "0", "]", "input_length", "=", "tf", ".", "shape", "(", "encoder_outputs", ")", "...
Return predicted sequence.
[ "Return", "predicted", "sequence", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/transformer.py#L217-L261
train
Predict the sequence of the encoder outputs.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
data_generation/fractal_graph_expansions/run_expansion.py
_create_row_col_indices
def _create_row_col_indices(ratings_df): """Maps user and items ids to their locations in the rating matrix.""" user_id_to_user_idx = _create_index(ratings_df, "userId") item_id_to_item_idx = _create_index(ratings_df, "movieId") ratings_df["row"] = ratings_df["userId"].apply( lambda x: user_id_to_user_id...
python
def _create_row_col_indices(ratings_df): """Maps user and items ids to their locations in the rating matrix.""" user_id_to_user_idx = _create_index(ratings_df, "userId") item_id_to_item_idx = _create_index(ratings_df, "movieId") ratings_df["row"] = ratings_df["userId"].apply( lambda x: user_id_to_user_id...
[ "def", "_create_row_col_indices", "(", "ratings_df", ")", ":", "user_id_to_user_idx", "=", "_create_index", "(", "ratings_df", ",", "\"userId\"", ")", "item_id_to_item_idx", "=", "_create_index", "(", "ratings_df", ",", "\"movieId\"", ")", "ratings_df", "[", "\"row\""...
Maps user and items ids to their locations in the rating matrix.
[ "Maps", "user", "and", "items", "ids", "to", "their", "locations", "in", "the", "rating", "matrix", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/data_generation/fractal_graph_expansions/run_expansion.py#L72-L82
train
Maps user and item ids to their locations in the rating matrix.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
data_generation/fractal_graph_expansions/run_expansion.py
_preprocess_movie_lens
def _preprocess_movie_lens(ratings_df): """Separate the rating datafram into train and test sets. Filters out users with less than two distinct timestamps. Creates train set and test set. The test set contains all the last interactions of users with more than two distinct timestamps. Args: ratings_df: p...
python
def _preprocess_movie_lens(ratings_df): """Separate the rating datafram into train and test sets. Filters out users with less than two distinct timestamps. Creates train set and test set. The test set contains all the last interactions of users with more than two distinct timestamps. Args: ratings_df: p...
[ "def", "_preprocess_movie_lens", "(", "ratings_df", ")", ":", "ratings_df", "[", "\"data\"", "]", "=", "1.0", "num_timestamps", "=", "ratings_df", "[", "[", "\"userId\"", ",", "\"timestamp\"", "]", "]", ".", "groupby", "(", "\"userId\"", ")", ".", "nunique", ...
Separate the rating datafram into train and test sets. Filters out users with less than two distinct timestamps. Creates train set and test set. The test set contains all the last interactions of users with more than two distinct timestamps. Args: ratings_df: pandas dataframe with columns 'userId', 'movie...
[ "Separate", "the", "rating", "datafram", "into", "train", "and", "test", "sets", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/data_generation/fractal_graph_expansions/run_expansion.py#L85-L119
train
Separate the rating datafram into train set and test set.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.getAnnIds
def getAnnIds(self, imgIds=[], catIds=[], areaRng=[], iscrowd=None): """ Get ann ids that satisfy given filter conditions. default skips that filter :param imgIds (int array) : get anns for given imgs catIds (int array) : get anns for given cats areaRng (f...
python
def getAnnIds(self, imgIds=[], catIds=[], areaRng=[], iscrowd=None): """ Get ann ids that satisfy given filter conditions. default skips that filter :param imgIds (int array) : get anns for given imgs catIds (int array) : get anns for given cats areaRng (f...
[ "def", "getAnnIds", "(", "self", ",", "imgIds", "=", "[", "]", ",", "catIds", "=", "[", "]", ",", "areaRng", "=", "[", "]", ",", "iscrowd", "=", "None", ")", ":", "imgIds", "=", "imgIds", "if", "_isArrayLike", "(", "imgIds", ")", "else", "[", "im...
Get ann ids that satisfy given filter conditions. default skips that filter :param imgIds (int array) : get anns for given imgs catIds (int array) : get anns for given cats areaRng (float array) : get anns for given area range (e.g. [0 inf]) iscrowd (bool...
[ "Get", "ann", "ids", "that", "satisfy", "given", "filter", "conditions", ".", "default", "skips", "that", "filter", ":", "param", "imgIds", "(", "int", "array", ")", ":", "get", "anns", "for", "given", "imgs", "catIds", "(", "int", "array", ")", ":", "...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L129-L155
train
Get an ann ids that satisfy given filter conditions. default skips that filter
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.getCatIds
def getCatIds(self, catNms=[], supNms=[], catIds=[]): """ filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given...
python
def getCatIds(self, catNms=[], supNms=[], catIds=[]): """ filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given...
[ "def", "getCatIds", "(", "self", ",", "catNms", "=", "[", "]", ",", "supNms", "=", "[", "]", ",", "catIds", "=", "[", "]", ")", ":", "catNms", "=", "catNms", "if", "_isArrayLike", "(", "catNms", ")", "else", "[", "catNms", "]", "supNms", "=", "su...
filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given cat ids :return: ids (int array) : integer array of cat ids
[ "filtering", "parameters", ".", "default", "skips", "that", "filter", ".", ":", "param", "catNms", "(", "str", "array", ")", ":", "get", "cats", "for", "given", "cat", "names", ":", "param", "supNms", "(", "str", "array", ")", ":", "get", "cats", "for"...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L157-L177
train
get the ids of the given categories
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.getImgIds
def getImgIds(self, imgIds=[], catIds=[]): ''' Get img ids that satisfy given filter conditions. :param imgIds (int array) : get imgs for given ids :param catIds (int array) : get imgs with all given cats :return: ids (int array) : integer array of img ids ''' im...
python
def getImgIds(self, imgIds=[], catIds=[]): ''' Get img ids that satisfy given filter conditions. :param imgIds (int array) : get imgs for given ids :param catIds (int array) : get imgs with all given cats :return: ids (int array) : integer array of img ids ''' im...
[ "def", "getImgIds", "(", "self", ",", "imgIds", "=", "[", "]", ",", "catIds", "=", "[", "]", ")", ":", "imgIds", "=", "imgIds", "if", "_isArrayLike", "(", "imgIds", ")", "else", "[", "imgIds", "]", "catIds", "=", "catIds", "if", "_isArrayLike", "(", ...
Get img ids that satisfy given filter conditions. :param imgIds (int array) : get imgs for given ids :param catIds (int array) : get imgs with all given cats :return: ids (int array) : integer array of img ids
[ "Get", "img", "ids", "that", "satisfy", "given", "filter", "conditions", ".", ":", "param", "imgIds", "(", "int", "array", ")", ":", "get", "imgs", "for", "given", "ids", ":", "param", "catIds", "(", "int", "array", ")", ":", "get", "imgs", "with", "...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L179-L198
train
Get img ids that satisfy given filter conditions.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.loadAnns
def loadAnns(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects """ if _isArrayLike(ids): return [self.anns[id] for id in ids] elif type(ids)...
python
def loadAnns(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects """ if _isArrayLike(ids): return [self.anns[id] for id in ids] elif type(ids)...
[ "def", "loadAnns", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "_isArrayLike", "(", "ids", ")", ":", "return", "[", "self", ".", "anns", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", "int", ...
Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects
[ "Load", "anns", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "anns", ":", "return", ":", "anns", "(", "object", "array", ")", ":", "loaded", "ann", "objects" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L200-L209
train
Load anns with the specified ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.loadCats
def loadCats(self, ids=[]): """ Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects """ if _isArrayLike(ids): return [self.cats[id] for id in ids] elif type(ids)...
python
def loadCats(self, ids=[]): """ Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects """ if _isArrayLike(ids): return [self.cats[id] for id in ids] elif type(ids)...
[ "def", "loadCats", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "_isArrayLike", "(", "ids", ")", ":", "return", "[", "self", ".", "cats", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", "int", ...
Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects
[ "Load", "cats", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "cats", ":", "return", ":", "cats", "(", "object", "array", ")", ":", "loaded", "cat", "objects" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L211-L220
train
Load cats with the specified ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.loadImgs
def loadImgs(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects """ if _isArrayLike(ids): return [self.imgs[id] for id in ids] elif type(ids) ...
python
def loadImgs(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects """ if _isArrayLike(ids): return [self.imgs[id] for id in ids] elif type(ids) ...
[ "def", "loadImgs", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "_isArrayLike", "(", "ids", ")", ":", "return", "[", "self", ".", "imgs", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", "int", ...
Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects
[ "Load", "anns", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "img", ":", "return", ":", "imgs", "(", "object", "array", ")", ":", "loaded", "img", "objects" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L222-L231
train
Load an img objects with the specified ids.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.showAnns
def showAnns(self, anns): """ Display the specified annotations. :param anns (array of object): annotations to display :return: None """ if len(anns) == 0: return 0 if 'segmentation' in anns[0] or 'keypoints' in anns[0]: datasetType = 'inst...
python
def showAnns(self, anns): """ Display the specified annotations. :param anns (array of object): annotations to display :return: None """ if len(anns) == 0: return 0 if 'segmentation' in anns[0] or 'keypoints' in anns[0]: datasetType = 'inst...
[ "def", "showAnns", "(", "self", ",", "anns", ")", ":", "if", "len", "(", "anns", ")", "==", "0", ":", "return", "0", "if", "'segmentation'", "in", "anns", "[", "0", "]", "or", "'keypoints'", "in", "anns", "[", "0", "]", ":", "datasetType", "=", "...
Display the specified annotations. :param anns (array of object): annotations to display :return: None
[ "Display", "the", "specified", "annotations", ".", ":", "param", "anns", "(", "array", "of", "object", ")", ":", "annotations", "to", "display", ":", "return", ":", "None" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L233-L295
train
Display the specified annotations.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.loadRes
def loadRes(self, resFile): """ Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object """ res = COCO() res.dataset['images'] = [img for img in self.dataset['images']] ...
python
def loadRes(self, resFile): """ Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object """ res = COCO() res.dataset['images'] = [img for img in self.dataset['images']] ...
[ "def", "loadRes", "(", "self", ",", "resFile", ")", ":", "res", "=", "COCO", "(", ")", "res", ".", "dataset", "[", "'images'", "]", "=", "[", "img", "for", "img", "in", "self", ".", "dataset", "[", "'images'", "]", "]", "print", "(", "'Loading and ...
Load result file and return a result api object. :param resFile (str) : file name of result file :return: res (obj) : result api object
[ "Load", "result", "file", "and", "return", "a", "result", "api", "object", ".", ":", "param", "resFile", "(", "str", ")", ":", "file", "name", "of", "result", "file", ":", "return", ":", "res", "(", "obj", ")", ":", "result", "api", "object" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L297-L356
train
Load a result file and return a result api object.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.annToRLE
def annToRLE(self, ann): """ Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array) """ t = self.imgs[ann['image_id']] h, w = t['height'], t['width'] segm = ann['segmentation'] if type(segm) == list: ...
python
def annToRLE(self, ann): """ Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array) """ t = self.imgs[ann['image_id']] h, w = t['height'], t['width'] segm = ann['segmentation'] if type(segm) == list: ...
[ "def", "annToRLE", "(", "self", ",", "ann", ")", ":", "t", "=", "self", ".", "imgs", "[", "ann", "[", "'image_id'", "]", "]", "h", ",", "w", "=", "t", "[", "'height'", "]", ",", "t", "[", "'width'", "]", "segm", "=", "ann", "[", "'segmentation'...
Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array)
[ "Convert", "annotation", "which", "can", "be", "polygons", "uncompressed", "RLE", "to", "RLE", ".", ":", "return", ":", "binary", "mask", "(", "numpy", "2D", "array", ")" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L405-L424
train
Convert annotation which can be polygons uncompressed RLE to binary mask
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
single_stage_detector/ssd/coco.py
COCO.annToMask
def annToMask(self, ann): """ Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask. :return: binary mask (numpy 2D array) """ rle = self.annToRLE(ann) m = maskUtils.decode(rle) return m
python
def annToMask(self, ann): """ Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask. :return: binary mask (numpy 2D array) """ rle = self.annToRLE(ann) m = maskUtils.decode(rle) return m
[ "def", "annToMask", "(", "self", ",", "ann", ")", ":", "rle", "=", "self", ".", "annToRLE", "(", "ann", ")", "m", "=", "maskUtils", ".", "decode", "(", "rle", ")", "return", "m" ]
Convert annotation which can be polygons, uncompressed RLE, or RLE to binary mask. :return: binary mask (numpy 2D array)
[ "Convert", "annotation", "which", "can", "be", "polygons", "uncompressed", "RLE", "or", "RLE", "to", "binary", "mask", ".", ":", "return", ":", "binary", "mask", "(", "numpy", "2D", "array", ")" ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/single_stage_detector/ssd/coco.py#L426-L433
train
Convert an annotation which can be polygons uncompressed RLE or RLE to binary mask.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
object_detection/pytorch/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py
GeneralizedRCNN.forward
def forward(self, images, targets=None): """ Arguments: images (list[Tensor] or ImageList): images to be processed targets (list[BoxList]): ground-truth boxes present in the image (optional) Returns: result (list[BoxList] or dict[Tensor]): the output from the...
python
def forward(self, images, targets=None): """ Arguments: images (list[Tensor] or ImageList): images to be processed targets (list[BoxList]): ground-truth boxes present in the image (optional) Returns: result (list[BoxList] or dict[Tensor]): the output from the...
[ "def", "forward", "(", "self", ",", "images", ",", "targets", "=", "None", ")", ":", "if", "self", ".", "training", "and", "targets", "is", "None", ":", "raise", "ValueError", "(", "\"In training mode, targets should be passed\"", ")", "images", "=", "to_image...
Arguments: images (list[Tensor] or ImageList): images to be processed targets (list[BoxList]): ground-truth boxes present in the image (optional) Returns: result (list[BoxList] or dict[Tensor]): the output from the model. During training, it returns a dict[Te...
[ "Arguments", ":", "images", "(", "list", "[", "Tensor", "]", "or", "ImageList", ")", ":", "images", "to", "be", "processed", "targets", "(", "list", "[", "BoxList", "]", ")", ":", "ground", "-", "truth", "boxes", "present", "in", "the", "image", "(", ...
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/object_detection/pytorch/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py#L33-L65
train
Forward the model to the next set of images and targets.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
data_generation/fractal_graph_expansions/graph_analysis.py
sparse_svd
def sparse_svd(sparse_matrix, num_values, max_iter): """Wrapper around SciPy's Singular Value Decomposition for sparse matrices. Args: sparse_matrix: a SciPy sparse matrix (typically large). num_values: the number of largest singular values to compute. max_iter: maximum number of iterations (>= 0) in t...
python
def sparse_svd(sparse_matrix, num_values, max_iter): """Wrapper around SciPy's Singular Value Decomposition for sparse matrices. Args: sparse_matrix: a SciPy sparse matrix (typically large). num_values: the number of largest singular values to compute. max_iter: maximum number of iterations (>= 0) in t...
[ "def", "sparse_svd", "(", "sparse_matrix", ",", "num_values", ",", "max_iter", ")", ":", "if", "num_values", "<=", "0", ":", "raise", "ValueError", "(", "\"num_values should be > 0 but instead is %d.\"", "%", "num_values", ")", "if", "max_iter", "is", "not", "None...
Wrapper around SciPy's Singular Value Decomposition for sparse matrices. Args: sparse_matrix: a SciPy sparse matrix (typically large). num_values: the number of largest singular values to compute. max_iter: maximum number of iterations (>= 0) in the decomposition. If max_iter is None, runs FLAGS.ma...
[ "Wrapper", "around", "SciPy", "s", "Singular", "Value", "Decomposition", "for", "sparse", "matrices", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/data_generation/fractal_graph_expansions/graph_analysis.py#L33-L64
train
Wrapper around SciPy s Singular Value Decomposition for sparse matrices.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/embedding_layer.py
EmbeddingSharedWeights.call
def call(self, x): """Get token embeddings of x. Args: x: An int64 tensor with shape [batch_size, length] Returns: embeddings: float32 tensor with shape [batch_size, length, embedding_size] padding: float32 tensor with shape [batch_size, length] indicating the locations of the pad...
python
def call(self, x): """Get token embeddings of x. Args: x: An int64 tensor with shape [batch_size, length] Returns: embeddings: float32 tensor with shape [batch_size, length, embedding_size] padding: float32 tensor with shape [batch_size, length] indicating the locations of the pad...
[ "def", "call", "(", "self", ",", "x", ")", ":", "with", "tf", ".", "name_scope", "(", "\"embedding\"", ")", ":", "embeddings", "=", "tf", ".", "gather", "(", "self", ".", "shared_weights", ",", "x", ")", "# Scale embedding by the sqrt of the hidden size", "e...
Get token embeddings of x. Args: x: An int64 tensor with shape [batch_size, length] Returns: embeddings: float32 tensor with shape [batch_size, length, embedding_size] padding: float32 tensor with shape [batch_size, length] indicating the locations of the padding tokens in x.
[ "Get", "token", "embeddings", "of", "x", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/embedding_layer.py#L53-L75
train
Get token embeddings of x.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
translation/tensorflow/transformer/model/embedding_layer.py
EmbeddingSharedWeights.linear
def linear(self, x): """Computes logits by running x through a linear layer. Args: x: A float32 tensor with shape [batch_size, length, hidden_size] Returns: float32 tensor with shape [batch_size, length, vocab_size]. """ with tf.name_scope("presoftmax_linear"): batch_size = tf.sha...
python
def linear(self, x): """Computes logits by running x through a linear layer. Args: x: A float32 tensor with shape [batch_size, length, hidden_size] Returns: float32 tensor with shape [batch_size, length, vocab_size]. """ with tf.name_scope("presoftmax_linear"): batch_size = tf.sha...
[ "def", "linear", "(", "self", ",", "x", ")", ":", "with", "tf", ".", "name_scope", "(", "\"presoftmax_linear\"", ")", ":", "batch_size", "=", "tf", ".", "shape", "(", "x", ")", "[", "0", "]", "length", "=", "tf", ".", "shape", "(", "x", ")", "[",...
Computes logits by running x through a linear layer. Args: x: A float32 tensor with shape [batch_size, length, hidden_size] Returns: float32 tensor with shape [batch_size, length, vocab_size].
[ "Computes", "logits", "by", "running", "x", "through", "a", "linear", "layer", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/translation/tensorflow/transformer/model/embedding_layer.py#L77-L92
train
Computes logits by running x through a linear layer.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/train/trainer.py
Seq2SeqTrainer.iterate
def iterate(self, src, tgt, update=True, training=True): """ Performs one iteration of the training/validation. :param src: batch of examples from the source language :param tgt: batch of examples from the target language :param update: if True: optimizer does update of the weig...
python
def iterate(self, src, tgt, update=True, training=True): """ Performs one iteration of the training/validation. :param src: batch of examples from the source language :param tgt: batch of examples from the target language :param update: if True: optimizer does update of the weig...
[ "def", "iterate", "(", "self", ",", "src", ",", "tgt", ",", "update", "=", "True", ",", "training", "=", "True", ")", ":", "src", ",", "src_length", "=", "src", "tgt", ",", "tgt_length", "=", "tgt", "src_length", "=", "torch", ".", "LongTensor", "(",...
Performs one iteration of the training/validation. :param src: batch of examples from the source language :param tgt: batch of examples from the target language :param update: if True: optimizer does update of the weights :param training: if True: executes optimizer
[ "Performs", "one", "iteration", "of", "the", "training", "/", "validation", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/train/trainer.py#L128-L173
train
Performs one iteration of the training and validation of the language.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/train/trainer.py
Seq2SeqTrainer.preallocate
def preallocate(self, data_loader, training): """ Generates maximum sequence length batch and runs forward and backward pass without updating model parameters. :param data_loader: data loader :param training: if True preallocates memory for backward pass """ batc...
python
def preallocate(self, data_loader, training): """ Generates maximum sequence length batch and runs forward and backward pass without updating model parameters. :param data_loader: data loader :param training: if True preallocates memory for backward pass """ batc...
[ "def", "preallocate", "(", "self", ",", "data_loader", ",", "training", ")", ":", "batch_size", "=", "data_loader", ".", "batch_size", "max_len", "=", "data_loader", ".", "dataset", ".", "max_len", "src_length", "=", "[", "max_len", "]", "*", "batch_size", "...
Generates maximum sequence length batch and runs forward and backward pass without updating model parameters. :param data_loader: data loader :param training: if True preallocates memory for backward pass
[ "Generates", "maximum", "sequence", "length", "batch", "and", "runs", "forward", "and", "backward", "pass", "without", "updating", "model", "parameters", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/train/trainer.py#L277-L301
train
Preallocate memory for the current cluster entry.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...
mlperf/training
rnn_translator/pytorch/seq2seq/train/trainer.py
Seq2SeqTrainer.optimize
def optimize(self, data_loader): """ Sets model in training mode, preallocates memory and runs training on data provided by data_loader. :param data_loader: data loader """ torch.set_grad_enabled(True) self.model.train() torch.cuda.empty_cache() s...
python
def optimize(self, data_loader): """ Sets model in training mode, preallocates memory and runs training on data provided by data_loader. :param data_loader: data loader """ torch.set_grad_enabled(True) self.model.train() torch.cuda.empty_cache() s...
[ "def", "optimize", "(", "self", ",", "data_loader", ")", ":", "torch", ".", "set_grad_enabled", "(", "True", ")", "self", ".", "model", ".", "train", "(", ")", "torch", ".", "cuda", ".", "empty_cache", "(", ")", "self", ".", "preallocate", "(", "data_l...
Sets model in training mode, preallocates memory and runs training on data provided by data_loader. :param data_loader: data loader
[ "Sets", "model", "in", "training", "mode", "preallocates", "memory", "and", "runs", "training", "on", "data", "provided", "by", "data_loader", "." ]
1c6ae725a81d15437a2b2df05cac0673fde5c3a4
https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/rnn_translator/pytorch/seq2seq/train/trainer.py#L303-L317
train
Sets model in training mode preallocates memory runs training on data provided by data_loader.
Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL...