repo stringlengths 7 55 | 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 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/losses.py | l2_regularizer | def l2_regularizer(weight=1.0, scope=None):
"""Define a L2 regularizer.
Args:
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function.
"""
def regularizer(tensor):
with tf.name_scope(scope, 'L2Regularizer', [tensor]):
l2_weight = tf.... | python | def l2_regularizer(weight=1.0, scope=None):
"""Define a L2 regularizer.
Args:
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function.
"""
def regularizer(tensor):
with tf.name_scope(scope, 'L2Regularizer', [tensor]):
l2_weight = tf.... | [
"def",
"l2_regularizer",
"(",
"weight",
"=",
"1.0",
",",
"scope",
"=",
"None",
")",
":",
"def",
"regularizer",
"(",
"tensor",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'L2Regularizer'",
",",
"[",
"tensor",
"]",
")",
":",
"l2_weight... | Define a L2 regularizer.
Args:
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function. | [
"Define",
"a",
"L2",
"regularizer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L56-L72 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/losses.py | l1_l2_regularizer | def l1_l2_regularizer(weight_l1=1.0, weight_l2=1.0, scope=None):
"""Define a L1L2 regularizer.
Args:
weight_l1: scale the L1 loss by this factor.
weight_l2: scale the L2 loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function.
"""
def regularizer(tensor):
... | python | def l1_l2_regularizer(weight_l1=1.0, weight_l2=1.0, scope=None):
"""Define a L1L2 regularizer.
Args:
weight_l1: scale the L1 loss by this factor.
weight_l2: scale the L2 loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function.
"""
def regularizer(tensor):
... | [
"def",
"l1_l2_regularizer",
"(",
"weight_l1",
"=",
"1.0",
",",
"weight_l2",
"=",
"1.0",
",",
"scope",
"=",
"None",
")",
":",
"def",
"regularizer",
"(",
"tensor",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'L1L2Regularizer'",
",",
"[",... | Define a L1L2 regularizer.
Args:
weight_l1: scale the L1 loss by this factor.
weight_l2: scale the L2 loss by this factor.
scope: Optional scope for name_scope.
Returns:
a regularizer function. | [
"Define",
"a",
"L1L2",
"regularizer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L75-L99 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/losses.py | l1_loss | def l1_loss(tensor, weight=1.0, scope=None):
"""Define a L1Loss, useful for regularize, i.e. lasso.
Args:
tensor: tensor to regularize.
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
the L1 loss op.
"""
with tf.name_scope(scope, 'L1Loss', [tensor]):
... | python | def l1_loss(tensor, weight=1.0, scope=None):
"""Define a L1Loss, useful for regularize, i.e. lasso.
Args:
tensor: tensor to regularize.
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
the L1 loss op.
"""
with tf.name_scope(scope, 'L1Loss', [tensor]):
... | [
"def",
"l1_loss",
"(",
"tensor",
",",
"weight",
"=",
"1.0",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'L1Loss'",
",",
"[",
"tensor",
"]",
")",
":",
"weight",
"=",
"tf",
".",
"convert_to_tensor",
"(",
... | Define a L1Loss, useful for regularize, i.e. lasso.
Args:
tensor: tensor to regularize.
weight: scale the loss by this factor.
scope: Optional scope for name_scope.
Returns:
the L1 loss op. | [
"Define",
"a",
"L1Loss",
"useful",
"for",
"regularize",
"i",
".",
"e",
".",
"lasso",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L102-L119 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/losses.py | l2_loss | def l2_loss(tensor, weight=1.0, scope=None):
"""Define a L2Loss, useful for regularize, i.e. weight decay.
Args:
tensor: tensor to regularize.
weight: an optional weight to modulate the loss.
scope: Optional scope for name_scope.
Returns:
the L2 loss op.
"""
with tf.name_scope(scope, 'L2Loss... | python | def l2_loss(tensor, weight=1.0, scope=None):
"""Define a L2Loss, useful for regularize, i.e. weight decay.
Args:
tensor: tensor to regularize.
weight: an optional weight to modulate the loss.
scope: Optional scope for name_scope.
Returns:
the L2 loss op.
"""
with tf.name_scope(scope, 'L2Loss... | [
"def",
"l2_loss",
"(",
"tensor",
",",
"weight",
"=",
"1.0",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'L2Loss'",
",",
"[",
"tensor",
"]",
")",
":",
"weight",
"=",
"tf",
".",
"convert_to_tensor",
"(",
... | Define a L2Loss, useful for regularize, i.e. weight decay.
Args:
tensor: tensor to regularize.
weight: an optional weight to modulate the loss.
scope: Optional scope for name_scope.
Returns:
the L2 loss op. | [
"Define",
"a",
"L2Loss",
"useful",
"for",
"regularize",
"i",
".",
"e",
".",
"weight",
"decay",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L122-L139 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/losses.py | cross_entropy_loss | def cross_entropy_loss(logits, one_hot_labels, label_smoothing=0,
weight=1.0, scope=None):
"""Define a Cross Entropy loss using softmax_cross_entropy_with_logits.
It can scale the loss by weight factor, and smooth the labels.
Args:
logits: [batch_size, num_classes] logits outputs of t... | python | def cross_entropy_loss(logits, one_hot_labels, label_smoothing=0,
weight=1.0, scope=None):
"""Define a Cross Entropy loss using softmax_cross_entropy_with_logits.
It can scale the loss by weight factor, and smooth the labels.
Args:
logits: [batch_size, num_classes] logits outputs of t... | [
"def",
"cross_entropy_loss",
"(",
"logits",
",",
"one_hot_labels",
",",
"label_smoothing",
"=",
"0",
",",
"weight",
"=",
"1.0",
",",
"scope",
"=",
"None",
")",
":",
"logits",
".",
"get_shape",
"(",
")",
".",
"assert_is_compatible_with",
"(",
"one_hot_labels",
... | Define a Cross Entropy loss using softmax_cross_entropy_with_logits.
It can scale the loss by weight factor, and smooth the labels.
Args:
logits: [batch_size, num_classes] logits outputs of the network .
one_hot_labels: [batch_size, num_classes] target one_hot_encoded labels.
label_smoothing: if great... | [
"Define",
"a",
"Cross",
"Entropy",
"loss",
"using",
"softmax_cross_entropy_with_logits",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/losses.py#L142-L174 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/scopes.py | arg_scope | def arg_scope(list_ops_or_scope, **kwargs):
"""Stores the default arguments for the given set of list_ops.
For usage, please see examples at top of the file.
Args:
list_ops_or_scope: List or tuple of operations to set argument scope for or
a dictionary containg the current scope. When list_ops_or_scop... | python | def arg_scope(list_ops_or_scope, **kwargs):
"""Stores the default arguments for the given set of list_ops.
For usage, please see examples at top of the file.
Args:
list_ops_or_scope: List or tuple of operations to set argument scope for or
a dictionary containg the current scope. When list_ops_or_scop... | [
"def",
"arg_scope",
"(",
"list_ops_or_scope",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"list_ops_or_scope",
",",
"dict",
")",
":",
"# Assumes that list_ops_or_scope is a scope that is being reused.",
"if",
"kwargs",
":",
"raise",
"ValueError",
"(",
... | Stores the default arguments for the given set of list_ops.
For usage, please see examples at top of the file.
Args:
list_ops_or_scope: List or tuple of operations to set argument scope for or
a dictionary containg the current scope. When list_ops_or_scope is a dict,
kwargs must be empty. When lis... | [
"Stores",
"the",
"default",
"arguments",
"for",
"the",
"given",
"set",
"of",
"list_ops",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/scopes.py#L85-L135 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/scopes.py | add_arg_scope | def add_arg_scope(func):
"""Decorates a function with args so it can be used within an arg_scope.
Args:
func: function to decorate.
Returns:
A tuple with the decorated function func_with_args().
"""
@functools.wraps(func)
def func_with_args(*args, **kwargs):
current_scope = _current_arg_scope(... | python | def add_arg_scope(func):
"""Decorates a function with args so it can be used within an arg_scope.
Args:
func: function to decorate.
Returns:
A tuple with the decorated function func_with_args().
"""
@functools.wraps(func)
def func_with_args(*args, **kwargs):
current_scope = _current_arg_scope(... | [
"def",
"add_arg_scope",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"func_with_args",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"current_scope",
"=",
"_current_arg_scope",
"(",
")",
"current_args",
"=",
"kwa... | Decorates a function with args so it can be used within an arg_scope.
Args:
func: function to decorate.
Returns:
A tuple with the decorated function func_with_args(). | [
"Decorates",
"a",
"function",
"with",
"args",
"so",
"it",
"can",
"be",
"used",
"within",
"an",
"arg_scope",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/scopes.py#L138-L157 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | _get_manager | def _get_manager(cluster_info, host, executor_id):
"""Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed.
Args:
:cluster_info: cluster node reservations
:host: host IP address
:executor_id: unique id per executor (created during initial... | python | def _get_manager(cluster_info, host, executor_id):
"""Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed.
Args:
:cluster_info: cluster node reservations
:host: host IP address
:executor_id: unique id per executor (created during initial... | [
"def",
"_get_manager",
"(",
"cluster_info",
",",
"host",
",",
"executor_id",
")",
":",
"for",
"node",
"in",
"cluster_info",
":",
"if",
"node",
"[",
"'host'",
"]",
"==",
"host",
"and",
"node",
"[",
"'executor_id'",
"]",
"==",
"executor_id",
":",
"addr",
"... | Returns this executor's "singleton" instance of the multiprocessing.Manager, reconnecting per python-worker if needed.
Args:
:cluster_info: cluster node reservations
:host: host IP address
:executor_id: unique id per executor (created during initial call to run())
Returns:
TFManager instance for t... | [
"Returns",
"this",
"executor",
"s",
"singleton",
"instance",
"of",
"the",
"multiprocessing",
".",
"Manager",
"reconnecting",
"per",
"python",
"-",
"worker",
"if",
"needed",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L91-L117 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | run | def run(fn, tf_args, cluster_meta, tensorboard, log_dir, queues, background):
"""Wraps the user-provided TensorFlow main function in a Spark mapPartitions function.
Args:
:fn: TensorFlow "main" function provided by the user.
:tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to th... | python | def run(fn, tf_args, cluster_meta, tensorboard, log_dir, queues, background):
"""Wraps the user-provided TensorFlow main function in a Spark mapPartitions function.
Args:
:fn: TensorFlow "main" function provided by the user.
:tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to th... | [
"def",
"run",
"(",
"fn",
",",
"tf_args",
",",
"cluster_meta",
",",
"tensorboard",
",",
"log_dir",
",",
"queues",
",",
"background",
")",
":",
"def",
"_mapfn",
"(",
"iter",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"# Note: consuming the input iterator help... | Wraps the user-provided TensorFlow main function in a Spark mapPartitions function.
Args:
:fn: TensorFlow "main" function provided by the user.
:tf_args: ``argparse`` args, or command line ``ARGV``. These will be passed to the ``fn``.
:cluster_meta: dictionary of cluster metadata (e.g. cluster_id, reser... | [
"Wraps",
"the",
"user",
"-",
"provided",
"TensorFlow",
"main",
"function",
"in",
"a",
"Spark",
"mapPartitions",
"function",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L120-L369 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | train | def train(cluster_info, cluster_meta, feed_timeout=600, qname='input'):
"""Feeds Spark partitions into the shared multiprocessing.Queue.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:cluster_meta: dictionary of cluster metadata (e.g. cluster_id... | python | def train(cluster_info, cluster_meta, feed_timeout=600, qname='input'):
"""Feeds Spark partitions into the shared multiprocessing.Queue.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:cluster_meta: dictionary of cluster metadata (e.g. cluster_id... | [
"def",
"train",
"(",
"cluster_info",
",",
"cluster_meta",
",",
"feed_timeout",
"=",
"600",
",",
"qname",
"=",
"'input'",
")",
":",
"def",
"_train",
"(",
"iter",
")",
":",
"# get shared queue, reconnecting if necessary",
"mgr",
"=",
"_get_manager",
"(",
"cluster_... | Feeds Spark partitions into the shared multiprocessing.Queue.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:cluster_meta: dictionary of cluster metadata (e.g. cluster_id, reservation.Server address, etc)
:feed_timeout: number of seconds after... | [
"Feeds",
"Spark",
"partitions",
"into",
"the",
"shared",
"multiprocessing",
".",
"Queue",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L372-L440 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | inference | def inference(cluster_info, feed_timeout=600, qname='input'):
"""Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:feed_timeout: number of seconds after whi... | python | def inference(cluster_info, feed_timeout=600, qname='input'):
"""Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:feed_timeout: number of seconds after whi... | [
"def",
"inference",
"(",
"cluster_info",
",",
"feed_timeout",
"=",
"600",
",",
"qname",
"=",
"'input'",
")",
":",
"def",
"_inference",
"(",
"iter",
")",
":",
"# get shared queue, reconnecting if necessary",
"mgr",
"=",
"_get_manager",
"(",
"cluster_info",
",",
"... | Feeds Spark partitions into the shared multiprocessing.Queue and returns inference results.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc)
:feed_timeout: number of seconds after which data feeding times out (600 sec default)
:qname: *INTERNAL_U... | [
"Feeds",
"Spark",
"partitions",
"into",
"the",
"shared",
"multiprocessing",
".",
"Queue",
"and",
"returns",
"inference",
"results",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L443-L505 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | shutdown | def shutdown(cluster_info, queues=['input']):
"""Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc).
:queues: *INTERNAL_USE*
Returns:
A nodeRDD.mapPartitions() fun... | python | def shutdown(cluster_info, queues=['input']):
"""Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc).
:queues: *INTERNAL_USE*
Returns:
A nodeRDD.mapPartitions() fun... | [
"def",
"shutdown",
"(",
"cluster_info",
",",
"queues",
"=",
"[",
"'input'",
"]",
")",
":",
"def",
"_shutdown",
"(",
"iter",
")",
":",
"host",
"=",
"util",
".",
"get_ip_address",
"(",
")",
"executor_id",
"=",
"util",
".",
"read_executor_id",
"(",
")",
"... | Stops all TensorFlow nodes by feeding ``None`` into the multiprocessing.Queues.
Args:
:cluster_info: node reservation information for the cluster (e.g. host, executor_id, pid, ports, etc).
:queues: *INTERNAL_USE*
Returns:
A nodeRDD.mapPartitions() function | [
"Stops",
"all",
"TensorFlow",
"nodes",
"by",
"feeding",
"None",
"into",
"the",
"multiprocessing",
".",
"Queues",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L508-L548 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | TFNodeContext.start_cluster_server | def start_cluster_server(self, num_gpus=1, rdma=False):
"""Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance."""
return TFNode.start_cluster_server(self, num_gpus, rdma) | python | def start_cluster_server(self, num_gpus=1, rdma=False):
"""Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance."""
return TFNode.start_cluster_server(self, num_gpus, rdma) | [
"def",
"start_cluster_server",
"(",
"self",
",",
"num_gpus",
"=",
"1",
",",
"rdma",
"=",
"False",
")",
":",
"return",
"TFNode",
".",
"start_cluster_server",
"(",
"self",
",",
"num_gpus",
",",
"rdma",
")"
] | Convenience function to access ``TFNode.start_cluster_server`` directly from this object instance. | [
"Convenience",
"function",
"to",
"access",
"TFNode",
".",
"start_cluster_server",
"directly",
"from",
"this",
"object",
"instance",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L61-L63 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | TFNodeContext.export_saved_model | def export_saved_model(self, sess, export_dir, tag_set, signatures):
"""Convenience function to access ``TFNode.export_saved_model`` directly from this object instance."""
TFNode.export_saved_model(sess, export_dir, tag_set, signatures) | python | def export_saved_model(self, sess, export_dir, tag_set, signatures):
"""Convenience function to access ``TFNode.export_saved_model`` directly from this object instance."""
TFNode.export_saved_model(sess, export_dir, tag_set, signatures) | [
"def",
"export_saved_model",
"(",
"self",
",",
"sess",
",",
"export_dir",
",",
"tag_set",
",",
"signatures",
")",
":",
"TFNode",
".",
"export_saved_model",
"(",
"sess",
",",
"export_dir",
",",
"tag_set",
",",
"signatures",
")"
] | Convenience function to access ``TFNode.export_saved_model`` directly from this object instance. | [
"Convenience",
"function",
"to",
"access",
"TFNode",
".",
"export_saved_model",
"directly",
"from",
"this",
"object",
"instance",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L65-L67 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFSparkNode.py | TFNodeContext.get_data_feed | def get_data_feed(self, train_mode=True, qname_in='input', qname_out='output', input_mapping=None):
"""Convenience function to access ``TFNode.DataFeed`` directly from this object instance."""
return TFNode.DataFeed(self.mgr, train_mode, qname_in, qname_out, input_mapping) | python | def get_data_feed(self, train_mode=True, qname_in='input', qname_out='output', input_mapping=None):
"""Convenience function to access ``TFNode.DataFeed`` directly from this object instance."""
return TFNode.DataFeed(self.mgr, train_mode, qname_in, qname_out, input_mapping) | [
"def",
"get_data_feed",
"(",
"self",
",",
"train_mode",
"=",
"True",
",",
"qname_in",
"=",
"'input'",
",",
"qname_out",
"=",
"'output'",
",",
"input_mapping",
"=",
"None",
")",
":",
"return",
"TFNode",
".",
"DataFeed",
"(",
"self",
".",
"mgr",
",",
"trai... | Convenience function to access ``TFNode.DataFeed`` directly from this object instance. | [
"Convenience",
"function",
"to",
"access",
"TFNode",
".",
"DataFeed",
"directly",
"from",
"this",
"object",
"instance",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFSparkNode.py#L69-L71 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/census_dataset.py | _download_and_clean_file | def _download_and_clean_file(filename, url):
"""Downloads data from url, and makes changes to match the CSV format."""
temp_file, _ = urllib.request.urlretrieve(url)
with tf.gfile.Open(temp_file, 'r') as temp_eval_file:
with tf.gfile.Open(filename, 'w') as eval_file:
for line in temp_eval_file:
... | python | def _download_and_clean_file(filename, url):
"""Downloads data from url, and makes changes to match the CSV format."""
temp_file, _ = urllib.request.urlretrieve(url)
with tf.gfile.Open(temp_file, 'r') as temp_eval_file:
with tf.gfile.Open(filename, 'w') as eval_file:
for line in temp_eval_file:
... | [
"def",
"_download_and_clean_file",
"(",
"filename",
",",
"url",
")",
":",
"temp_file",
",",
"_",
"=",
"urllib",
".",
"request",
".",
"urlretrieve",
"(",
"url",
")",
"with",
"tf",
".",
"gfile",
".",
"Open",
"(",
"temp_file",
",",
"'r'",
")",
"as",
"temp... | Downloads data from url, and makes changes to match the CSV format. | [
"Downloads",
"data",
"from",
"url",
"and",
"makes",
"changes",
"to",
"match",
"the",
"CSV",
"format",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L59-L73 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/census_dataset.py | download | def download(data_dir):
"""Download census data if it is not already present."""
tf.gfile.MakeDirs(data_dir)
training_file_path = os.path.join(data_dir, TRAINING_FILE)
if not tf.gfile.Exists(training_file_path):
_download_and_clean_file(training_file_path, TRAINING_URL)
eval_file_path = os.path.join(dat... | python | def download(data_dir):
"""Download census data if it is not already present."""
tf.gfile.MakeDirs(data_dir)
training_file_path = os.path.join(data_dir, TRAINING_FILE)
if not tf.gfile.Exists(training_file_path):
_download_and_clean_file(training_file_path, TRAINING_URL)
eval_file_path = os.path.join(dat... | [
"def",
"download",
"(",
"data_dir",
")",
":",
"tf",
".",
"gfile",
".",
"MakeDirs",
"(",
"data_dir",
")",
"training_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"TRAINING_FILE",
")",
"if",
"not",
"tf",
".",
"gfile",
".",
"Exist... | Download census data if it is not already present. | [
"Download",
"census",
"data",
"if",
"it",
"is",
"not",
"already",
"present",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L76-L86 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/census_dataset.py | build_model_columns | def build_model_columns():
"""Builds a set of wide and deep feature columns."""
# Continuous variable columns
age = tf.feature_column.numeric_column('age')
education_num = tf.feature_column.numeric_column('education_num')
capital_gain = tf.feature_column.numeric_column('capital_gain')
capital_loss = tf.feat... | python | def build_model_columns():
"""Builds a set of wide and deep feature columns."""
# Continuous variable columns
age = tf.feature_column.numeric_column('age')
education_num = tf.feature_column.numeric_column('education_num')
capital_gain = tf.feature_column.numeric_column('capital_gain')
capital_loss = tf.feat... | [
"def",
"build_model_columns",
"(",
")",
":",
"# Continuous variable columns",
"age",
"=",
"tf",
".",
"feature_column",
".",
"numeric_column",
"(",
"'age'",
")",
"education_num",
"=",
"tf",
".",
"feature_column",
".",
"numeric_column",
"(",
"'education_num'",
")",
... | Builds a set of wide and deep feature columns. | [
"Builds",
"a",
"set",
"of",
"wide",
"and",
"deep",
"feature",
"columns",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L89-L157 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/census_dataset.py | input_fn | def input_fn(data_file, num_epochs, shuffle, batch_size):
"""Generate an input function for the Estimator."""
assert tf.gfile.Exists(data_file), (
'%s not found. Please make sure you have run census_dataset.py and '
'set the --data_dir argument to the correct path.' % data_file)
def parse_csv(value):... | python | def input_fn(data_file, num_epochs, shuffle, batch_size):
"""Generate an input function for the Estimator."""
assert tf.gfile.Exists(data_file), (
'%s not found. Please make sure you have run census_dataset.py and '
'set the --data_dir argument to the correct path.' % data_file)
def parse_csv(value):... | [
"def",
"input_fn",
"(",
"data_file",
",",
"num_epochs",
",",
"shuffle",
",",
"batch_size",
")",
":",
"assert",
"tf",
".",
"gfile",
".",
"Exists",
"(",
"data_file",
")",
",",
"(",
"'%s not found. Please make sure you have run census_dataset.py and '",
"'set the --data_... | Generate an input function for the Estimator. | [
"Generate",
"an",
"input",
"function",
"for",
"the",
"Estimator",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/census_dataset.py#L160-L186 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | MessageSocket.receive | def receive(self, sock):
"""Receive a message on ``sock``."""
msg = None
data = b''
recv_done = False
recv_len = -1
while not recv_done:
buf = sock.recv(BUFSIZE)
if buf is None or len(buf) == 0:
raise Exception("socket closed")
if recv_len == -1:
recv_len = stru... | python | def receive(self, sock):
"""Receive a message on ``sock``."""
msg = None
data = b''
recv_done = False
recv_len = -1
while not recv_done:
buf = sock.recv(BUFSIZE)
if buf is None or len(buf) == 0:
raise Exception("socket closed")
if recv_len == -1:
recv_len = stru... | [
"def",
"receive",
"(",
"self",
",",
"sock",
")",
":",
"msg",
"=",
"None",
"data",
"=",
"b''",
"recv_done",
"=",
"False",
"recv_len",
"=",
"-",
"1",
"while",
"not",
"recv_done",
":",
"buf",
"=",
"sock",
".",
"recv",
"(",
"BUFSIZE",
")",
"if",
"buf",... | Receive a message on ``sock``. | [
"Receive",
"a",
"message",
"on",
"sock",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L69-L89 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | MessageSocket.send | def send(self, sock, msg):
"""Send ``msg`` to destination ``sock``."""
data = pickle.dumps(msg)
buf = struct.pack('>I', len(data)) + data
sock.sendall(buf) | python | def send(self, sock, msg):
"""Send ``msg`` to destination ``sock``."""
data = pickle.dumps(msg)
buf = struct.pack('>I', len(data)) + data
sock.sendall(buf) | [
"def",
"send",
"(",
"self",
",",
"sock",
",",
"msg",
")",
":",
"data",
"=",
"pickle",
".",
"dumps",
"(",
"msg",
")",
"buf",
"=",
"struct",
".",
"pack",
"(",
"'>I'",
",",
"len",
"(",
"data",
")",
")",
"+",
"data",
"sock",
".",
"sendall",
"(",
... | Send ``msg`` to destination ``sock``. | [
"Send",
"msg",
"to",
"destination",
"sock",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L91-L95 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | Server.await_reservations | def await_reservations(self, sc, status={}, timeout=600):
"""Block until all reservations are received."""
timespent = 0
while not self.reservations.done():
logging.info("waiting for {0} reservations".format(self.reservations.remaining()))
# check status flags for any errors
if 'error' in ... | python | def await_reservations(self, sc, status={}, timeout=600):
"""Block until all reservations are received."""
timespent = 0
while not self.reservations.done():
logging.info("waiting for {0} reservations".format(self.reservations.remaining()))
# check status flags for any errors
if 'error' in ... | [
"def",
"await_reservations",
"(",
"self",
",",
"sc",
",",
"status",
"=",
"{",
"}",
",",
"timeout",
"=",
"600",
")",
":",
"timespent",
"=",
"0",
"while",
"not",
"self",
".",
"reservations",
".",
"done",
"(",
")",
":",
"logging",
".",
"info",
"(",
"\... | Block until all reservations are received. | [
"Block",
"until",
"all",
"reservations",
"are",
"received",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L111-L126 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | Server.start | def start(self):
"""Start listener in a background thread
Returns:
address of the Server as a tuple of (host, port)
"""
server_sock = self.start_listening_socket()
# hostname may not be resolvable but IP address probably will be
host = self.get_server_ip()
port = server_sock.getsockn... | python | def start(self):
"""Start listener in a background thread
Returns:
address of the Server as a tuple of (host, port)
"""
server_sock = self.start_listening_socket()
# hostname may not be resolvable but IP address probably will be
host = self.get_server_ip()
port = server_sock.getsockn... | [
"def",
"start",
"(",
"self",
")",
":",
"server_sock",
"=",
"self",
".",
"start_listening_socket",
"(",
")",
"# hostname may not be resolvable but IP address probably will be",
"host",
"=",
"self",
".",
"get_server_ip",
"(",
")",
"port",
"=",
"server_sock",
".",
"get... | Start listener in a background thread
Returns:
address of the Server as a tuple of (host, port) | [
"Start",
"listener",
"in",
"a",
"background",
"thread"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L146-L186 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | Client._request | def _request(self, msg_type, msg_data=None):
"""Helper function to wrap msg w/ msg_type."""
msg = {}
msg['type'] = msg_type
if msg_data:
msg['data'] = msg_data
done = False
tries = 0
while not done and tries < MAX_RETRIES:
try:
MessageSocket.send(self, self.sock, msg)
... | python | def _request(self, msg_type, msg_data=None):
"""Helper function to wrap msg w/ msg_type."""
msg = {}
msg['type'] = msg_type
if msg_data:
msg['data'] = msg_data
done = False
tries = 0
while not done and tries < MAX_RETRIES:
try:
MessageSocket.send(self, self.sock, msg)
... | [
"def",
"_request",
"(",
"self",
",",
"msg_type",
",",
"msg_data",
"=",
"None",
")",
":",
"msg",
"=",
"{",
"}",
"msg",
"[",
"'type'",
"]",
"=",
"msg_type",
"if",
"msg_data",
":",
"msg",
"[",
"'data'",
"]",
"=",
"msg_data",
"done",
"=",
"False",
"tri... | Helper function to wrap msg w/ msg_type. | [
"Helper",
"function",
"to",
"wrap",
"msg",
"w",
"/",
"msg_type",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L220-L245 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/reservation.py | Client.await_reservations | def await_reservations(self):
"""Poll until all reservations completed, then return cluster_info."""
done = False
while not done:
done = self._request('QUERY')
time.sleep(1)
return self.get_reservations() | python | def await_reservations(self):
"""Poll until all reservations completed, then return cluster_info."""
done = False
while not done:
done = self._request('QUERY')
time.sleep(1)
return self.get_reservations() | [
"def",
"await_reservations",
"(",
"self",
")",
":",
"done",
"=",
"False",
"while",
"not",
"done",
":",
"done",
"=",
"self",
".",
"_request",
"(",
"'QUERY'",
")",
"time",
".",
"sleep",
"(",
"1",
")",
"return",
"self",
".",
"get_reservations",
"(",
")"
] | Poll until all reservations completed, then return cluster_info. | [
"Poll",
"until",
"all",
"reservations",
"completed",
"then",
"return",
"cluster_info",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/reservation.py#L261-L267 | train |
yahoo/TensorFlowOnSpark | examples/mnist/mnist_data_setup.py | toTFExample | def toTFExample(image, label):
"""Serializes an image/label as a TFExample byte string"""
example = tf.train.Example(
features=tf.train.Features(
feature={
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=label.astype("int64"))),
'image': tf.train.Feature(int64_list=tf.train.I... | python | def toTFExample(image, label):
"""Serializes an image/label as a TFExample byte string"""
example = tf.train.Example(
features=tf.train.Features(
feature={
'label': tf.train.Feature(int64_list=tf.train.Int64List(value=label.astype("int64"))),
'image': tf.train.Feature(int64_list=tf.train.I... | [
"def",
"toTFExample",
"(",
"image",
",",
"label",
")",
":",
"example",
"=",
"tf",
".",
"train",
".",
"Example",
"(",
"features",
"=",
"tf",
".",
"train",
".",
"Features",
"(",
"feature",
"=",
"{",
"'label'",
":",
"tf",
".",
"train",
".",
"Feature",
... | Serializes an image/label as a TFExample byte string | [
"Serializes",
"an",
"image",
"/",
"label",
"as",
"a",
"TFExample",
"byte",
"string"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/mnist_data_setup.py#L14-L24 | train |
yahoo/TensorFlowOnSpark | examples/mnist/mnist_data_setup.py | fromTFExample | def fromTFExample(bytestr):
"""Deserializes a TFExample from a byte string"""
example = tf.train.Example()
example.ParseFromString(bytestr)
return example | python | def fromTFExample(bytestr):
"""Deserializes a TFExample from a byte string"""
example = tf.train.Example()
example.ParseFromString(bytestr)
return example | [
"def",
"fromTFExample",
"(",
"bytestr",
")",
":",
"example",
"=",
"tf",
".",
"train",
".",
"Example",
"(",
")",
"example",
".",
"ParseFromString",
"(",
"bytestr",
")",
"return",
"example"
] | Deserializes a TFExample from a byte string | [
"Deserializes",
"a",
"TFExample",
"from",
"a",
"byte",
"string"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/mnist_data_setup.py#L27-L31 | train |
yahoo/TensorFlowOnSpark | examples/mnist/mnist_data_setup.py | writeMNIST | def writeMNIST(sc, input_images, input_labels, output, format, num_partitions):
"""Writes MNIST image/label vectors into parallelized files on HDFS"""
# load MNIST gzip into memory
with open(input_images, 'rb') as f:
images = numpy.array(mnist.extract_images(f))
with open(input_labels, 'rb') as f:
if f... | python | def writeMNIST(sc, input_images, input_labels, output, format, num_partitions):
"""Writes MNIST image/label vectors into parallelized files on HDFS"""
# load MNIST gzip into memory
with open(input_images, 'rb') as f:
images = numpy.array(mnist.extract_images(f))
with open(input_labels, 'rb') as f:
if f... | [
"def",
"writeMNIST",
"(",
"sc",
",",
"input_images",
",",
"input_labels",
",",
"output",
",",
"format",
",",
"num_partitions",
")",
":",
"# load MNIST gzip into memory",
"with",
"open",
"(",
"input_images",
",",
"'rb'",
")",
"as",
"f",
":",
"images",
"=",
"n... | Writes MNIST image/label vectors into parallelized files on HDFS | [
"Writes",
"MNIST",
"image",
"/",
"label",
"vectors",
"into",
"parallelized",
"files",
"on",
"HDFS"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/mnist_data_setup.py#L44-L81 | train |
yahoo/TensorFlowOnSpark | examples/mnist/mnist_data_setup.py | readMNIST | def readMNIST(sc, output, format):
"""Reads/verifies previously created output"""
output_images = output + "/images"
output_labels = output + "/labels"
imageRDD = None
labelRDD = None
if format == "pickle":
imageRDD = sc.pickleFile(output_images)
labelRDD = sc.pickleFile(output_labels)
elif form... | python | def readMNIST(sc, output, format):
"""Reads/verifies previously created output"""
output_images = output + "/images"
output_labels = output + "/labels"
imageRDD = None
labelRDD = None
if format == "pickle":
imageRDD = sc.pickleFile(output_images)
labelRDD = sc.pickleFile(output_labels)
elif form... | [
"def",
"readMNIST",
"(",
"sc",
",",
"output",
",",
"format",
")",
":",
"output_images",
"=",
"output",
"+",
"\"/images\"",
"output_labels",
"=",
"output",
"+",
"\"/labels\"",
"imageRDD",
"=",
"None",
"labelRDD",
"=",
"None",
"if",
"format",
"==",
"\"pickle\"... | Reads/verifies previously created output | [
"Reads",
"/",
"verifies",
"previously",
"created",
"output"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/mnist_data_setup.py#L94-L120 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_model.py | inference | def inference(images, num_classes, for_training=False, restore_logits=True,
scope=None):
"""Build Inception v3 model architecture.
See here for reference: http://arxiv.org/abs/1512.00567
Args:
images: Images returned from inputs() or distorted_inputs().
num_classes: number of classes
f... | python | def inference(images, num_classes, for_training=False, restore_logits=True,
scope=None):
"""Build Inception v3 model architecture.
See here for reference: http://arxiv.org/abs/1512.00567
Args:
images: Images returned from inputs() or distorted_inputs().
num_classes: number of classes
f... | [
"def",
"inference",
"(",
"images",
",",
"num_classes",
",",
"for_training",
"=",
"False",
",",
"restore_logits",
"=",
"True",
",",
"scope",
"=",
"None",
")",
":",
"# Parameters for BatchNorm.",
"batch_norm_params",
"=",
"{",
"# Decay for the moving averages.",
"'dec... | Build Inception v3 model architecture.
See here for reference: http://arxiv.org/abs/1512.00567
Args:
images: Images returned from inputs() or distorted_inputs().
num_classes: number of classes
for_training: If set to `True`, build the inference model for training.
Kernels that operate differentl... | [
"Build",
"Inception",
"v3",
"model",
"architecture",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_model.py#L48-L95 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_model.py | loss | def loss(logits, labels, batch_size=None):
"""Adds all losses for the model.
Note the final loss is not returned. Instead, the list of losses are collected
by slim.losses. The losses are accumulated in tower_loss() and summed to
calculate the total loss.
Args:
logits: List of logits from inference(). Ea... | python | def loss(logits, labels, batch_size=None):
"""Adds all losses for the model.
Note the final loss is not returned. Instead, the list of losses are collected
by slim.losses. The losses are accumulated in tower_loss() and summed to
calculate the total loss.
Args:
logits: List of logits from inference(). Ea... | [
"def",
"loss",
"(",
"logits",
",",
"labels",
",",
"batch_size",
"=",
"None",
")",
":",
"if",
"not",
"batch_size",
":",
"batch_size",
"=",
"FLAGS",
".",
"batch_size",
"# Reshape the labels into a dense Tensor of",
"# shape [FLAGS.batch_size, num_classes].",
"sparse_label... | Adds all losses for the model.
Note the final loss is not returned. Instead, the list of losses are collected
by slim.losses. The losses are accumulated in tower_loss() and summed to
calculate the total loss.
Args:
logits: List of logits from inference(). Each entry is a 2-D float Tensor.
labels: Labe... | [
"Adds",
"all",
"losses",
"for",
"the",
"model",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_model.py#L98-L135 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | hdfs_path | def hdfs_path(ctx, path):
"""Convenience function to create a Tensorflow-compatible absolute HDFS path from relative paths
Args:
:ctx: TFNodeContext containing the metadata specific to this node in the cluster.
:path: path to convert
Returns:
An absolute path prefixed with the correct filesystem sch... | python | def hdfs_path(ctx, path):
"""Convenience function to create a Tensorflow-compatible absolute HDFS path from relative paths
Args:
:ctx: TFNodeContext containing the metadata specific to this node in the cluster.
:path: path to convert
Returns:
An absolute path prefixed with the correct filesystem sch... | [
"def",
"hdfs_path",
"(",
"ctx",
",",
"path",
")",
":",
"# All Hadoop-Compatible File System Schemes (as of Hadoop 3.0.x):",
"HADOOP_SCHEMES",
"=",
"[",
"'adl://'",
",",
"'file://'",
",",
"'hdfs://'",
",",
"'oss://'",
",",
"'s3://'",
",",
"'s3a://'",
",",
"'s3n://'",
... | Convenience function to create a Tensorflow-compatible absolute HDFS path from relative paths
Args:
:ctx: TFNodeContext containing the metadata specific to this node in the cluster.
:path: path to convert
Returns:
An absolute path prefixed with the correct filesystem scheme. | [
"Convenience",
"function",
"to",
"create",
"a",
"Tensorflow",
"-",
"compatible",
"absolute",
"HDFS",
"path",
"from",
"relative",
"paths"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L25-L60 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | start_cluster_server | def start_cluster_server(ctx, num_gpus=1, rdma=False):
"""Function that wraps the creation of TensorFlow ``tf.train.Server`` for a node in a distributed TensorFlow cluster.
This is intended to be invoked from within the TF ``map_fun``, replacing explicit code to instantiate ``tf.train.ClusterSpec``
and ``tf.trai... | python | def start_cluster_server(ctx, num_gpus=1, rdma=False):
"""Function that wraps the creation of TensorFlow ``tf.train.Server`` for a node in a distributed TensorFlow cluster.
This is intended to be invoked from within the TF ``map_fun``, replacing explicit code to instantiate ``tf.train.ClusterSpec``
and ``tf.trai... | [
"def",
"start_cluster_server",
"(",
"ctx",
",",
"num_gpus",
"=",
"1",
",",
"rdma",
"=",
"False",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"from",
".",
"import",
"gpu_info",
"logging",
".",
"info",
"(",
"\"{0}: ======== {1}:{2} ========\"",
".",
"format",
... | Function that wraps the creation of TensorFlow ``tf.train.Server`` for a node in a distributed TensorFlow cluster.
This is intended to be invoked from within the TF ``map_fun``, replacing explicit code to instantiate ``tf.train.ClusterSpec``
and ``tf.train.Server`` objects.
Args:
:ctx: TFNodeContext contain... | [
"Function",
"that",
"wraps",
"the",
"creation",
"of",
"TensorFlow",
"tf",
".",
"train",
".",
"Server",
"for",
"a",
"node",
"in",
"a",
"distributed",
"TensorFlow",
"cluster",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L63-L136 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | export_saved_model | def export_saved_model(sess, export_dir, tag_set, signatures):
"""Convenience function to export a saved_model using provided arguments
The caller specifies the saved_model signatures in a simplified python dictionary form, as follows::
signatures = {
'signature_def_key': {
'inputs': { 'input_te... | python | def export_saved_model(sess, export_dir, tag_set, signatures):
"""Convenience function to export a saved_model using provided arguments
The caller specifies the saved_model signatures in a simplified python dictionary form, as follows::
signatures = {
'signature_def_key': {
'inputs': { 'input_te... | [
"def",
"export_saved_model",
"(",
"sess",
",",
"export_dir",
",",
"tag_set",
",",
"signatures",
")",
":",
"import",
"tensorflow",
"as",
"tf",
"g",
"=",
"sess",
".",
"graph",
"g",
".",
"_unsafe_unfinalize",
"(",
")",
"# https://github.com/tensorflow/serving/issues/... | Convenience function to export a saved_model using provided arguments
The caller specifies the saved_model signatures in a simplified python dictionary form, as follows::
signatures = {
'signature_def_key': {
'inputs': { 'input_tensor_alias': input_tensor_name },
'outputs': { 'output_tenso... | [
"Convenience",
"function",
"to",
"export",
"a",
"saved_model",
"using",
"provided",
"arguments"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L144-L187 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | DataFeed.next_batch | def next_batch(self, batch_size):
"""Gets a batch of items from the input RDD.
If multiple tensors are provided per row in the input RDD, e.g. tuple of (tensor1, tensor2, ..., tensorN) and:
* no ``input_mapping`` was provided to the DataFeed constructor, this will return an array of ``batch_size`` tuples,... | python | def next_batch(self, batch_size):
"""Gets a batch of items from the input RDD.
If multiple tensors are provided per row in the input RDD, e.g. tuple of (tensor1, tensor2, ..., tensorN) and:
* no ``input_mapping`` was provided to the DataFeed constructor, this will return an array of ``batch_size`` tuples,... | [
"def",
"next_batch",
"(",
"self",
",",
"batch_size",
")",
":",
"logging",
".",
"debug",
"(",
"\"next_batch() invoked\"",
")",
"queue",
"=",
"self",
".",
"mgr",
".",
"get_queue",
"(",
"self",
".",
"qname_in",
")",
"tensors",
"=",
"[",
"]",
"if",
"self",
... | Gets a batch of items from the input RDD.
If multiple tensors are provided per row in the input RDD, e.g. tuple of (tensor1, tensor2, ..., tensorN) and:
* no ``input_mapping`` was provided to the DataFeed constructor, this will return an array of ``batch_size`` tuples,
and the caller is responsible for ... | [
"Gets",
"a",
"batch",
"of",
"items",
"from",
"the",
"input",
"RDD",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L219-L265 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | DataFeed.batch_results | def batch_results(self, results):
"""Push a batch of output results to the Spark output RDD of ``TFCluster.inference()``.
Note: this currently expects a one-to-one mapping of input to output data, so the length of the ``results`` array should match the length of
the previously retrieved batch of input data... | python | def batch_results(self, results):
"""Push a batch of output results to the Spark output RDD of ``TFCluster.inference()``.
Note: this currently expects a one-to-one mapping of input to output data, so the length of the ``results`` array should match the length of
the previously retrieved batch of input data... | [
"def",
"batch_results",
"(",
"self",
",",
"results",
")",
":",
"logging",
".",
"debug",
"(",
"\"batch_results() invoked\"",
")",
"queue",
"=",
"self",
".",
"mgr",
".",
"get_queue",
"(",
"self",
".",
"qname_out",
")",
"for",
"item",
"in",
"results",
":",
... | Push a batch of output results to the Spark output RDD of ``TFCluster.inference()``.
Note: this currently expects a one-to-one mapping of input to output data, so the length of the ``results`` array should match the length of
the previously retrieved batch of input data.
Args:
:results: array of out... | [
"Push",
"a",
"batch",
"of",
"output",
"results",
"to",
"the",
"Spark",
"output",
"RDD",
"of",
"TFCluster",
".",
"inference",
"()",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L271-L284 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/TFNode.py | DataFeed.terminate | def terminate(self):
"""Terminate data feeding early.
Since TensorFlow applications can often terminate on conditions unrelated to the training data (e.g. steps, accuracy, etc),
this method signals the data feeding process to ignore any further incoming data. Note that Spark itself does not have a mechani... | python | def terminate(self):
"""Terminate data feeding early.
Since TensorFlow applications can often terminate on conditions unrelated to the training data (e.g. steps, accuracy, etc),
this method signals the data feeding process to ignore any further incoming data. Note that Spark itself does not have a mechani... | [
"def",
"terminate",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"\"terminate() invoked\"",
")",
"self",
".",
"mgr",
".",
"set",
"(",
"'state'",
",",
"'terminating'",
")",
"# drop remaining items in the queue",
"queue",
"=",
"self",
".",
"mgr",
".",
"... | Terminate data feeding early.
Since TensorFlow applications can often terminate on conditions unrelated to the training data (e.g. steps, accuracy, etc),
this method signals the data feeding process to ignore any further incoming data. Note that Spark itself does not have a mechanism
to terminate an RDD o... | [
"Terminate",
"data",
"feeding",
"early",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/TFNode.py#L286-L308 | train |
yahoo/TensorFlowOnSpark | examples/mnist/tf/mnist_dist_pipeline.py | export_fun | def export_fun(args):
"""Define/export a single-node TF graph for inferencing"""
# Input placeholder for inferencing
x = tf.placeholder(tf.float32, [None, IMAGE_PIXELS * IMAGE_PIXELS], name="x")
# Variables of the hidden layer
hid_w = tf.Variable(tf.truncated_normal([IMAGE_PIXELS * IMAGE_PIXELS, hidden_units... | python | def export_fun(args):
"""Define/export a single-node TF graph for inferencing"""
# Input placeholder for inferencing
x = tf.placeholder(tf.float32, [None, IMAGE_PIXELS * IMAGE_PIXELS], name="x")
# Variables of the hidden layer
hid_w = tf.Variable(tf.truncated_normal([IMAGE_PIXELS * IMAGE_PIXELS, hidden_units... | [
"def",
"export_fun",
"(",
"args",
")",
":",
"# Input placeholder for inferencing",
"x",
"=",
"tf",
".",
"placeholder",
"(",
"tf",
".",
"float32",
",",
"[",
"None",
",",
"IMAGE_PIXELS",
"*",
"IMAGE_PIXELS",
"]",
",",
"name",
"=",
"\"x\"",
")",
"# Variables of... | Define/export a single-node TF graph for inferencing | [
"Define",
"/",
"export",
"a",
"single",
"-",
"node",
"TF",
"graph",
"for",
"inferencing"
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/mnist/tf/mnist_dist_pipeline.py#L136-L185 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_distributed_train.py | train | def train(target, dataset, cluster_spec, ctx):
"""Train Inception on a dataset for a number of steps."""
# Number of workers and parameter servers are infered from the workers and ps
# hosts string.
num_workers = len(cluster_spec.as_dict()['worker'])
num_parameter_servers = len(cluster_spec.as_dict()['ps'])
... | python | def train(target, dataset, cluster_spec, ctx):
"""Train Inception on a dataset for a number of steps."""
# Number of workers and parameter servers are infered from the workers and ps
# hosts string.
num_workers = len(cluster_spec.as_dict()['worker'])
num_parameter_servers = len(cluster_spec.as_dict()['ps'])
... | [
"def",
"train",
"(",
"target",
",",
"dataset",
",",
"cluster_spec",
",",
"ctx",
")",
":",
"# Number of workers and parameter servers are infered from the workers and ps",
"# hosts string.",
"num_workers",
"=",
"len",
"(",
"cluster_spec",
".",
"as_dict",
"(",
")",
"[",
... | Train Inception on a dataset for a number of steps. | [
"Train",
"Inception",
"on",
"a",
"dataset",
"for",
"a",
"number",
"of",
"steps",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_distributed_train.py#L96-L360 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_export.py | export | def export(_):
FLAGS = tf.app.flags.FLAGS
"""Evaluate model on Dataset for a number of steps."""
#with tf.Graph().as_default():
tf.reset_default_graph()
def preprocess_image(image_buffer):
"""Preprocess JPEG encoded bytes to 3D float Tensor."""
# Decode the string as an RGB JPEG.
# Note that th... | python | def export(_):
FLAGS = tf.app.flags.FLAGS
"""Evaluate model on Dataset for a number of steps."""
#with tf.Graph().as_default():
tf.reset_default_graph()
def preprocess_image(image_buffer):
"""Preprocess JPEG encoded bytes to 3D float Tensor."""
# Decode the string as an RGB JPEG.
# Note that th... | [
"def",
"export",
"(",
"_",
")",
":",
"FLAGS",
"=",
"tf",
".",
"app",
".",
"flags",
".",
"FLAGS",
"#with tf.Graph().as_default():",
"tf",
".",
"reset_default_graph",
"(",
")",
"def",
"preprocess_image",
"(",
"image_buffer",
")",
":",
"\"\"\"Preprocess JPEG encode... | Evaluate model on Dataset for a number of steps. | [
"Evaluate",
"model",
"on",
"Dataset",
"for",
"a",
"number",
"of",
"steps",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_export.py#L30-L115 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/gpu_info.py | _get_gpu | def _get_gpu():
"""*DEPRECATED*. Allocates first available GPU using cudaSetDevice(), or returns 0 otherwise."""
# Note: this code executes, but Tensorflow subsequently complains that the "current context was not created by the StreamExecutor cuda_driver API"
system = platform.system()
if system == "Linux":
... | python | def _get_gpu():
"""*DEPRECATED*. Allocates first available GPU using cudaSetDevice(), or returns 0 otherwise."""
# Note: this code executes, but Tensorflow subsequently complains that the "current context was not created by the StreamExecutor cuda_driver API"
system = platform.system()
if system == "Linux":
... | [
"def",
"_get_gpu",
"(",
")",
":",
"# Note: this code executes, but Tensorflow subsequently complains that the \"current context was not created by the StreamExecutor cuda_driver API\"",
"system",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"system",
"==",
"\"Linux\"",
":",
"l... | *DEPRECATED*. Allocates first available GPU using cudaSetDevice(), or returns 0 otherwise. | [
"*",
"DEPRECATED",
"*",
".",
"Allocates",
"first",
"available",
"GPU",
"using",
"cudaSetDevice",
"()",
"or",
"returns",
"0",
"otherwise",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/gpu_info.py#L20-L40 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/gpu_info.py | get_gpus | def get_gpus(num_gpu=1, worker_index=-1):
"""Get list of free GPUs according to nvidia-smi.
This will retry for ``MAX_RETRIES`` times until the requested number of GPUs are available.
Args:
:num_gpu: number of GPUs desired.
:worker_index: index "hint" for allocation of available GPUs.
Returns:
Co... | python | def get_gpus(num_gpu=1, worker_index=-1):
"""Get list of free GPUs according to nvidia-smi.
This will retry for ``MAX_RETRIES`` times until the requested number of GPUs are available.
Args:
:num_gpu: number of GPUs desired.
:worker_index: index "hint" for allocation of available GPUs.
Returns:
Co... | [
"def",
"get_gpus",
"(",
"num_gpu",
"=",
"1",
",",
"worker_index",
"=",
"-",
"1",
")",
":",
"# get list of gpus (index, uuid)",
"list_gpus",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"nvidia-smi\"",
",",
"\"--list-gpus\"",
"]",
")",
".",
"decode",
"("... | Get list of free GPUs according to nvidia-smi.
This will retry for ``MAX_RETRIES`` times until the requested number of GPUs are available.
Args:
:num_gpu: number of GPUs desired.
:worker_index: index "hint" for allocation of available GPUs.
Returns:
Comma-delimited string of GPU ids, or raises an E... | [
"Get",
"list",
"of",
"free",
"GPUs",
"according",
"to",
"nvidia",
"-",
"smi",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/gpu_info.py#L43-L104 | train |
yahoo/TensorFlowOnSpark | tensorflowonspark/gpu_info.py | _get_free_gpu | def _get_free_gpu(max_gpu_utilization=40, min_free_memory=0.5, num_gpu=1):
"""Get available GPUs according to utilization thresholds.
Args:
:max_gpu_utilization: percent utilization threshold to consider a GPU "free"
:min_free_memory: percent free memory to consider a GPU "free"
:num_gpu: number of req... | python | def _get_free_gpu(max_gpu_utilization=40, min_free_memory=0.5, num_gpu=1):
"""Get available GPUs according to utilization thresholds.
Args:
:max_gpu_utilization: percent utilization threshold to consider a GPU "free"
:min_free_memory: percent free memory to consider a GPU "free"
:num_gpu: number of req... | [
"def",
"_get_free_gpu",
"(",
"max_gpu_utilization",
"=",
"40",
",",
"min_free_memory",
"=",
"0.5",
",",
"num_gpu",
"=",
"1",
")",
":",
"def",
"get_gpu_info",
"(",
")",
":",
"# Get the gpu information",
"gpu_info",
"=",
"subprocess",
".",
"check_output",
"(",
"... | Get available GPUs according to utilization thresholds.
Args:
:max_gpu_utilization: percent utilization threshold to consider a GPU "free"
:min_free_memory: percent free memory to consider a GPU "free"
:num_gpu: number of requested GPUs
Returns:
A tuple of (available_gpus, minimum_free_memory), wh... | [
"Get",
"available",
"GPUs",
"according",
"to",
"utilization",
"thresholds",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/tensorflowonspark/gpu_info.py#L108-L177 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/data/build_image_data.py | _convert_to_example | def _convert_to_example(filename, image_buffer, label, text, height, width):
"""Build an Example proto for an example.
Args:
filename: string, path to an image file, e.g., '/path/to/example.JPG'
image_buffer: string, JPEG encoding of RGB image
label: integer, identifier for the ground truth for the net... | python | def _convert_to_example(filename, image_buffer, label, text, height, width):
"""Build an Example proto for an example.
Args:
filename: string, path to an image file, e.g., '/path/to/example.JPG'
image_buffer: string, JPEG encoding of RGB image
label: integer, identifier for the ground truth for the net... | [
"def",
"_convert_to_example",
"(",
"filename",
",",
"image_buffer",
",",
"label",
",",
"text",
",",
"height",
",",
"width",
")",
":",
"colorspace",
"=",
"'RGB'",
"channels",
"=",
"3",
"image_format",
"=",
"'JPEG'",
"example",
"=",
"tf",
".",
"train",
".",
... | Build an Example proto for an example.
Args:
filename: string, path to an image file, e.g., '/path/to/example.JPG'
image_buffer: string, JPEG encoding of RGB image
label: integer, identifier for the ground truth for the network
text: string, unique human-readable, e.g. 'dog'
height: integer, imag... | [
"Build",
"an",
"Example",
"proto",
"for",
"an",
"example",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_image_data.py#L119-L147 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/data/build_image_data.py | _process_image_files_batch | def _process_image_files_batch(coder, thread_index, ranges, name, filenames,
texts, labels, num_shards):
"""Processes and saves list of images as TFRecord in 1 thread.
Args:
coder: instance of ImageCoder to provide TensorFlow image coding utils.
thread_index: integer, unique ... | python | def _process_image_files_batch(coder, thread_index, ranges, name, filenames,
texts, labels, num_shards):
"""Processes and saves list of images as TFRecord in 1 thread.
Args:
coder: instance of ImageCoder to provide TensorFlow image coding utils.
thread_index: integer, unique ... | [
"def",
"_process_image_files_batch",
"(",
"coder",
",",
"thread_index",
",",
"ranges",
",",
"name",
",",
"filenames",
",",
"texts",
",",
"labels",
",",
"num_shards",
")",
":",
"# Each thread produces N shards where N = int(num_shards / num_threads).",
"# For instance, if nu... | Processes and saves list of images as TFRecord in 1 thread.
Args:
coder: instance of ImageCoder to provide TensorFlow image coding utils.
thread_index: integer, unique batch to run index is within [0, len(ranges)).
ranges: list of pairs of integers specifying ranges of each batches to
analyze in pa... | [
"Processes",
"and",
"saves",
"list",
"of",
"images",
"as",
"TFRecord",
"in",
"1",
"thread",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_image_data.py#L222-L284 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/data/build_image_data.py | _process_image_files | def _process_image_files(name, filenames, texts, labels, num_shards):
"""Process and save list of images as TFRecord of Example protos.
Args:
name: string, unique identifier specifying the data set
filenames: list of strings; each string is a path to an image file
texts: list of strings; each string is... | python | def _process_image_files(name, filenames, texts, labels, num_shards):
"""Process and save list of images as TFRecord of Example protos.
Args:
name: string, unique identifier specifying the data set
filenames: list of strings; each string is a path to an image file
texts: list of strings; each string is... | [
"def",
"_process_image_files",
"(",
"name",
",",
"filenames",
",",
"texts",
",",
"labels",
",",
"num_shards",
")",
":",
"assert",
"len",
"(",
"filenames",
")",
"==",
"len",
"(",
"texts",
")",
"assert",
"len",
"(",
"filenames",
")",
"==",
"len",
"(",
"l... | Process and save list of images as TFRecord of Example protos.
Args:
name: string, unique identifier specifying the data set
filenames: list of strings; each string is a path to an image file
texts: list of strings; each string is human readable, e.g. 'dog'
labels: list of integer; each integer ident... | [
"Process",
"and",
"save",
"list",
"of",
"images",
"as",
"TFRecord",
"of",
"Example",
"protos",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_image_data.py#L287-L328 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/data/build_image_data.py | _find_image_files | def _find_image_files(data_dir, labels_file):
"""Build a list of all images files and labels in the data set.
Args:
data_dir: string, path to the root directory of images.
Assumes that the image data set resides in JPEG files located in
the following directory structure.
data_dir/dog/anot... | python | def _find_image_files(data_dir, labels_file):
"""Build a list of all images files and labels in the data set.
Args:
data_dir: string, path to the root directory of images.
Assumes that the image data set resides in JPEG files located in
the following directory structure.
data_dir/dog/anot... | [
"def",
"_find_image_files",
"(",
"data_dir",
",",
"labels_file",
")",
":",
"print",
"(",
"'Determining list of input files and labels from %s.'",
"%",
"data_dir",
")",
"unique_labels",
"=",
"[",
"l",
".",
"strip",
"(",
")",
"for",
"l",
"in",
"tf",
".",
"gfile",
... | Build a list of all images files and labels in the data set.
Args:
data_dir: string, path to the root directory of images.
Assumes that the image data set resides in JPEG files located in
the following directory structure.
data_dir/dog/another-image.JPEG
data_dir/dog/my-image.jpg
... | [
"Build",
"a",
"list",
"of",
"all",
"images",
"files",
"and",
"labels",
"in",
"the",
"data",
"set",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_image_data.py#L331-L399 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/data/build_image_data.py | _process_dataset | def _process_dataset(name, directory, num_shards, labels_file):
"""Process a complete data set and save it as a TFRecord.
Args:
name: string, unique identifier specifying the data set.
directory: string, root path to the data set.
num_shards: integer number of shards for this data set.
labels_file:... | python | def _process_dataset(name, directory, num_shards, labels_file):
"""Process a complete data set and save it as a TFRecord.
Args:
name: string, unique identifier specifying the data set.
directory: string, root path to the data set.
num_shards: integer number of shards for this data set.
labels_file:... | [
"def",
"_process_dataset",
"(",
"name",
",",
"directory",
",",
"num_shards",
",",
"labels_file",
")",
":",
"filenames",
",",
"texts",
",",
"labels",
"=",
"_find_image_files",
"(",
"directory",
",",
"labels_file",
")",
"_process_image_files",
"(",
"name",
",",
... | Process a complete data set and save it as a TFRecord.
Args:
name: string, unique identifier specifying the data set.
directory: string, root path to the data set.
num_shards: integer number of shards for this data set.
labels_file: string, path to the labels file. | [
"Process",
"a",
"complete",
"data",
"set",
"and",
"save",
"it",
"as",
"a",
"TFRecord",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/data/build_image_data.py#L402-L412 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | inputs | def inputs(dataset, batch_size=None, num_preprocess_threads=None):
"""Generate batches of ImageNet images for evaluation.
Use this function as the inputs for evaluating a network.
Note that some (minimal) image preprocessing occurs during evaluation
including central cropping and resizing of the image to fit ... | python | def inputs(dataset, batch_size=None, num_preprocess_threads=None):
"""Generate batches of ImageNet images for evaluation.
Use this function as the inputs for evaluating a network.
Note that some (minimal) image preprocessing occurs during evaluation
including central cropping and resizing of the image to fit ... | [
"def",
"inputs",
"(",
"dataset",
",",
"batch_size",
"=",
"None",
",",
"num_preprocess_threads",
"=",
"None",
")",
":",
"if",
"not",
"batch_size",
":",
"batch_size",
"=",
"FLAGS",
".",
"batch_size",
"# Force all input processing onto CPU in order to reserve the GPU for",... | Generate batches of ImageNet images for evaluation.
Use this function as the inputs for evaluating a network.
Note that some (minimal) image preprocessing occurs during evaluation
including central cropping and resizing of the image to fit the network.
Args:
dataset: instance of Dataset class specifying ... | [
"Generate",
"batches",
"of",
"ImageNet",
"images",
"for",
"evaluation",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L74-L104 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | distorted_inputs | def distorted_inputs(dataset, batch_size=None, num_preprocess_threads=None):
"""Generate batches of distorted versions of ImageNet images.
Use this function as the inputs for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the netw... | python | def distorted_inputs(dataset, batch_size=None, num_preprocess_threads=None):
"""Generate batches of distorted versions of ImageNet images.
Use this function as the inputs for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the netw... | [
"def",
"distorted_inputs",
"(",
"dataset",
",",
"batch_size",
"=",
"None",
",",
"num_preprocess_threads",
"=",
"None",
")",
":",
"if",
"not",
"batch_size",
":",
"batch_size",
"=",
"FLAGS",
".",
"batch_size",
"# Force all input processing onto CPU in order to reserve the... | Generate batches of distorted versions of ImageNet images.
Use this function as the inputs for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the network invariant to aspects
of the image that do not effect the label.
Args:
... | [
"Generate",
"batches",
"of",
"distorted",
"versions",
"of",
"ImageNet",
"images",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L107-L137 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | decode_jpeg | def decode_jpeg(image_buffer, scope=None):
"""Decode a JPEG string into one 3-D float image Tensor.
Args:
image_buffer: scalar string Tensor.
scope: Optional scope for name_scope.
Returns:
3-D float Tensor with values ranging from [0, 1).
"""
with tf.name_scope(values=[image_buffer], name=scope,
... | python | def decode_jpeg(image_buffer, scope=None):
"""Decode a JPEG string into one 3-D float image Tensor.
Args:
image_buffer: scalar string Tensor.
scope: Optional scope for name_scope.
Returns:
3-D float Tensor with values ranging from [0, 1).
"""
with tf.name_scope(values=[image_buffer], name=scope,
... | [
"def",
"decode_jpeg",
"(",
"image_buffer",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"values",
"=",
"[",
"image_buffer",
"]",
",",
"name",
"=",
"scope",
",",
"default_name",
"=",
"'decode_jpeg'",
")",
":",
"# Decode the str... | Decode a JPEG string into one 3-D float image Tensor.
Args:
image_buffer: scalar string Tensor.
scope: Optional scope for name_scope.
Returns:
3-D float Tensor with values ranging from [0, 1). | [
"Decode",
"a",
"JPEG",
"string",
"into",
"one",
"3",
"-",
"D",
"float",
"image",
"Tensor",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L140-L161 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | distort_color | def distort_color(image, thread_id=0, scope=None):
"""Distort the color of the image.
Each color distortion is non-commutative and thus ordering of the color ops
matters. Ideally we would randomly permute the ordering of the color ops.
Rather then adding that level of complication, we select a distinct orderin... | python | def distort_color(image, thread_id=0, scope=None):
"""Distort the color of the image.
Each color distortion is non-commutative and thus ordering of the color ops
matters. Ideally we would randomly permute the ordering of the color ops.
Rather then adding that level of complication, we select a distinct orderin... | [
"def",
"distort_color",
"(",
"image",
",",
"thread_id",
"=",
"0",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"values",
"=",
"[",
"image",
"]",
",",
"name",
"=",
"scope",
",",
"default_name",
"=",
"'distort_color'",
")",
... | Distort the color of the image.
Each color distortion is non-commutative and thus ordering of the color ops
matters. Ideally we would randomly permute the ordering of the color ops.
Rather then adding that level of complication, we select a distinct ordering
of color ops for each preprocessing thread.
Args:... | [
"Distort",
"the",
"color",
"of",
"the",
"image",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L164-L195 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | distort_image | def distort_image(image, height, width, bbox, thread_id=0, scope=None):
"""Distort one image for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the network invariant to aspects
of the image that do not effect the label.
Args:
... | python | def distort_image(image, height, width, bbox, thread_id=0, scope=None):
"""Distort one image for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the network invariant to aspects
of the image that do not effect the label.
Args:
... | [
"def",
"distort_image",
"(",
"image",
",",
"height",
",",
"width",
",",
"bbox",
",",
"thread_id",
"=",
"0",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"values",
"=",
"[",
"image",
",",
"height",
",",
"width",
",",
"b... | Distort one image for training a network.
Distorting images provides a useful technique for augmenting the data
set during training in order to make the network invariant to aspects
of the image that do not effect the label.
Args:
image: 3-D float Tensor of image
height: integer
width: integer
... | [
"Distort",
"one",
"image",
"for",
"training",
"a",
"network",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L198-L276 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | eval_image | def eval_image(image, height, width, scope=None):
"""Prepare one image for evaluation.
Args:
image: 3-D float Tensor
height: integer
width: integer
scope: Optional scope for name_scope.
Returns:
3-D float Tensor of prepared image.
"""
with tf.name_scope(values=[image, height, width], name... | python | def eval_image(image, height, width, scope=None):
"""Prepare one image for evaluation.
Args:
image: 3-D float Tensor
height: integer
width: integer
scope: Optional scope for name_scope.
Returns:
3-D float Tensor of prepared image.
"""
with tf.name_scope(values=[image, height, width], name... | [
"def",
"eval_image",
"(",
"image",
",",
"height",
",",
"width",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"values",
"=",
"[",
"image",
",",
"height",
",",
"width",
"]",
",",
"name",
"=",
"scope",
",",
"default_name",
... | Prepare one image for evaluation.
Args:
image: 3-D float Tensor
height: integer
width: integer
scope: Optional scope for name_scope.
Returns:
3-D float Tensor of prepared image. | [
"Prepare",
"one",
"image",
"for",
"evaluation",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L279-L301 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | image_preprocessing | def image_preprocessing(image_buffer, bbox, train, thread_id=0):
"""Decode and preprocess one image for evaluation or training.
Args:
image_buffer: JPEG encoded string Tensor
bbox: 3-D float Tensor of bounding boxes arranged [1, num_boxes, coords]
where each coordinate is [0, 1) and the coordinates a... | python | def image_preprocessing(image_buffer, bbox, train, thread_id=0):
"""Decode and preprocess one image for evaluation or training.
Args:
image_buffer: JPEG encoded string Tensor
bbox: 3-D float Tensor of bounding boxes arranged [1, num_boxes, coords]
where each coordinate is [0, 1) and the coordinates a... | [
"def",
"image_preprocessing",
"(",
"image_buffer",
",",
"bbox",
",",
"train",
",",
"thread_id",
"=",
"0",
")",
":",
"if",
"bbox",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Please supply a bounding box.'",
")",
"image",
"=",
"decode_jpeg",
"(",
"image_bu... | Decode and preprocess one image for evaluation or training.
Args:
image_buffer: JPEG encoded string Tensor
bbox: 3-D float Tensor of bounding boxes arranged [1, num_boxes, coords]
where each coordinate is [0, 1) and the coordinates are arranged as
[ymin, xmin, ymax, xmax].
train: boolean
... | [
"Decode",
"and",
"preprocess",
"one",
"image",
"for",
"evaluation",
"or",
"training",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L304-L336 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | parse_example_proto | def parse_example_proto(example_serialized):
"""Parses an Example proto containing a training example of an image.
The output of the build_image_data.py image preprocessing script is a dataset
containing serialized Example protocol buffers. Each Example proto contains
the following fields:
image/height: 4... | python | def parse_example_proto(example_serialized):
"""Parses an Example proto containing a training example of an image.
The output of the build_image_data.py image preprocessing script is a dataset
containing serialized Example protocol buffers. Each Example proto contains
the following fields:
image/height: 4... | [
"def",
"parse_example_proto",
"(",
"example_serialized",
")",
":",
"# Dense features in Example proto.",
"feature_map",
"=",
"{",
"'image/encoded'",
":",
"tf",
".",
"FixedLenFeature",
"(",
"[",
"]",
",",
"dtype",
"=",
"tf",
".",
"string",
",",
"default_value",
"="... | Parses an Example proto containing a training example of an image.
The output of the build_image_data.py image preprocessing script is a dataset
containing serialized Example protocol buffers. Each Example proto contains
the following fields:
image/height: 462
image/width: 581
image/colorspace: 'RGB... | [
"Parses",
"an",
"Example",
"proto",
"containing",
"a",
"training",
"example",
"of",
"an",
"image",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L339-L407 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/image_processing.py | batch_inputs | def batch_inputs(dataset, batch_size, train, num_preprocess_threads=None,
num_readers=1):
"""Contruct batches of training or evaluation examples from the image dataset.
Args:
dataset: instance of Dataset class specifying the dataset.
See dataset.py for details.
batch_size: integer
... | python | def batch_inputs(dataset, batch_size, train, num_preprocess_threads=None,
num_readers=1):
"""Contruct batches of training or evaluation examples from the image dataset.
Args:
dataset: instance of Dataset class specifying the dataset.
See dataset.py for details.
batch_size: integer
... | [
"def",
"batch_inputs",
"(",
"dataset",
",",
"batch_size",
",",
"train",
",",
"num_preprocess_threads",
"=",
"None",
",",
"num_readers",
"=",
"1",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"'batch_processing'",
")",
":",
"data_files",
"=",
"dataset",
".... | Contruct batches of training or evaluation examples from the image dataset.
Args:
dataset: instance of Dataset class specifying the dataset.
See dataset.py for details.
batch_size: integer
train: boolean
num_preprocess_threads: integer, total number of preprocessing threads
num_readers: int... | [
"Contruct",
"batches",
"of",
"training",
"or",
"evaluation",
"examples",
"from",
"the",
"image",
"dataset",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/image_processing.py#L410-L513 | train |
yahoo/TensorFlowOnSpark | scripts/spark_ec2.py | setup_external_libs | def setup_external_libs(libs):
"""
Download external libraries from PyPI to SPARK_EC2_DIR/lib/ and prepend them to our PATH.
"""
PYPI_URL_PREFIX = "https://pypi.python.org/packages/source"
SPARK_EC2_LIB_DIR = os.path.join(SPARK_EC2_DIR, "lib")
if not os.path.exists(SPARK_EC2_LIB_DIR):
p... | python | def setup_external_libs(libs):
"""
Download external libraries from PyPI to SPARK_EC2_DIR/lib/ and prepend them to our PATH.
"""
PYPI_URL_PREFIX = "https://pypi.python.org/packages/source"
SPARK_EC2_LIB_DIR = os.path.join(SPARK_EC2_DIR, "lib")
if not os.path.exists(SPARK_EC2_LIB_DIR):
p... | [
"def",
"setup_external_libs",
"(",
"libs",
")",
":",
"PYPI_URL_PREFIX",
"=",
"\"https://pypi.python.org/packages/source\"",
"SPARK_EC2_LIB_DIR",
"=",
"os",
".",
"path",
".",
"join",
"(",
"SPARK_EC2_DIR",
",",
"\"lib\"",
")",
"if",
"not",
"os",
".",
"path",
".",
... | Download external libraries from PyPI to SPARK_EC2_DIR/lib/ and prepend them to our PATH. | [
"Download",
"external",
"libraries",
"from",
"PyPI",
"to",
"SPARK_EC2_DIR",
"/",
"lib",
"/",
"and",
"prepend",
"them",
"to",
"our",
"PATH",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/scripts/spark_ec2.py#L111-L151 | train |
yahoo/TensorFlowOnSpark | scripts/spark_ec2.py | get_existing_cluster | def get_existing_cluster(conn, opts, cluster_name, die_on_error=True):
"""
Get the EC2 instances in an existing cluster if available.
Returns a tuple of lists of EC2 instance objects for the masters and slaves.
"""
print("Searching for existing cluster {c} in region {r}...".format(
c=clust... | python | def get_existing_cluster(conn, opts, cluster_name, die_on_error=True):
"""
Get the EC2 instances in an existing cluster if available.
Returns a tuple of lists of EC2 instance objects for the masters and slaves.
"""
print("Searching for existing cluster {c} in region {r}...".format(
c=clust... | [
"def",
"get_existing_cluster",
"(",
"conn",
",",
"opts",
",",
"cluster_name",
",",
"die_on_error",
"=",
"True",
")",
":",
"print",
"(",
"\"Searching for existing cluster {c} in region {r}...\"",
".",
"format",
"(",
"c",
"=",
"cluster_name",
",",
"r",
"=",
"opts",
... | Get the EC2 instances in an existing cluster if available.
Returns a tuple of lists of EC2 instance objects for the masters and slaves. | [
"Get",
"the",
"EC2",
"instances",
"in",
"an",
"existing",
"cluster",
"if",
"available",
".",
"Returns",
"a",
"tuple",
"of",
"lists",
"of",
"EC2",
"instance",
"objects",
"for",
"the",
"masters",
"and",
"slaves",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/scripts/spark_ec2.py#L757-L792 | train |
yahoo/TensorFlowOnSpark | scripts/spark_ec2.py | is_ssh_available | def is_ssh_available(host, opts, print_ssh_output=True):
"""
Check if SSH is available on a host.
"""
s = subprocess.Popen(
ssh_command(opts) + ['-t', '-t', '-o', 'ConnectTimeout=3',
'%s@%s' % (opts.user, host), stringify_command('true')],
stdout=subprocess.P... | python | def is_ssh_available(host, opts, print_ssh_output=True):
"""
Check if SSH is available on a host.
"""
s = subprocess.Popen(
ssh_command(opts) + ['-t', '-t', '-o', 'ConnectTimeout=3',
'%s@%s' % (opts.user, host), stringify_command('true')],
stdout=subprocess.P... | [
"def",
"is_ssh_available",
"(",
"host",
",",
"opts",
",",
"print_ssh_output",
"=",
"True",
")",
":",
"s",
"=",
"subprocess",
".",
"Popen",
"(",
"ssh_command",
"(",
"opts",
")",
"+",
"[",
"'-t'",
",",
"'-t'",
",",
"'-o'",
",",
"'ConnectTimeout=3'",
",",
... | Check if SSH is available on a host. | [
"Check",
"if",
"SSH",
"is",
"available",
"on",
"a",
"host",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/scripts/spark_ec2.py#L882-L907 | train |
yahoo/TensorFlowOnSpark | scripts/spark_ec2.py | is_cluster_ssh_available | def is_cluster_ssh_available(cluster_instances, opts):
"""
Check if SSH is available on all the instances in a cluster.
"""
for i in cluster_instances:
dns_name = get_dns_name(i, opts.private_ips)
if not is_ssh_available(host=dns_name, opts=opts):
return False
else:
... | python | def is_cluster_ssh_available(cluster_instances, opts):
"""
Check if SSH is available on all the instances in a cluster.
"""
for i in cluster_instances:
dns_name = get_dns_name(i, opts.private_ips)
if not is_ssh_available(host=dns_name, opts=opts):
return False
else:
... | [
"def",
"is_cluster_ssh_available",
"(",
"cluster_instances",
",",
"opts",
")",
":",
"for",
"i",
"in",
"cluster_instances",
":",
"dns_name",
"=",
"get_dns_name",
"(",
"i",
",",
"opts",
".",
"private_ips",
")",
"if",
"not",
"is_ssh_available",
"(",
"host",
"=",
... | Check if SSH is available on all the instances in a cluster. | [
"Check",
"if",
"SSH",
"is",
"available",
"on",
"all",
"the",
"instances",
"in",
"a",
"cluster",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/scripts/spark_ec2.py#L910-L919 | train |
yahoo/TensorFlowOnSpark | scripts/spark_ec2.py | wait_for_cluster_state | def wait_for_cluster_state(conn, opts, cluster_instances, cluster_state):
"""
Wait for all the instances in the cluster to reach a designated state.
cluster_instances: a list of boto.ec2.instance.Instance
cluster_state: a string representing the desired state of all the instances in the cluster
... | python | def wait_for_cluster_state(conn, opts, cluster_instances, cluster_state):
"""
Wait for all the instances in the cluster to reach a designated state.
cluster_instances: a list of boto.ec2.instance.Instance
cluster_state: a string representing the desired state of all the instances in the cluster
... | [
"def",
"wait_for_cluster_state",
"(",
"conn",
",",
"opts",
",",
"cluster_instances",
",",
"cluster_state",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"Waiting for cluster to enter '{s}' state.\"",
".",
"format",
"(",
"s",
"=",
"cluster_state",
")",
")",
... | Wait for all the instances in the cluster to reach a designated state.
cluster_instances: a list of boto.ec2.instance.Instance
cluster_state: a string representing the desired state of all the instances in the cluster
value can be 'ssh-ready' or a valid value from boto.ec2.instance.InstanceState suc... | [
"Wait",
"for",
"all",
"the",
"instances",
"in",
"the",
"cluster",
"to",
"reach",
"a",
"designated",
"state",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/scripts/spark_ec2.py#L922-L973 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/imagenet_data.py | ImagenetData.download_message | def download_message(self):
"""Instruction to download and extract the tarball from Flowers website."""
print('Failed to find any ImageNet %s files'% self.subset)
print('')
print('If you have already downloaded and processed the data, then make '
'sure to set --data_dir to point to the direct... | python | def download_message(self):
"""Instruction to download and extract the tarball from Flowers website."""
print('Failed to find any ImageNet %s files'% self.subset)
print('')
print('If you have already downloaded and processed the data, then make '
'sure to set --data_dir to point to the direct... | [
"def",
"download_message",
"(",
"self",
")",
":",
"print",
"(",
"'Failed to find any ImageNet %s files'",
"%",
"self",
".",
"subset",
")",
"print",
"(",
"''",
")",
"print",
"(",
"'If you have already downloaded and processed the data, then make '",
"'sure to set --data_dir ... | Instruction to download and extract the tarball from Flowers website. | [
"Instruction",
"to",
"download",
"and",
"extract",
"the",
"tarball",
"from",
"Flowers",
"website",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/imagenet_data.py#L44-L59 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/wide_deep_run_loop.py | define_wide_deep_flags | def define_wide_deep_flags():
"""Add supervised learning flags, as well as wide-deep model type."""
flags_core.define_base()
flags_core.define_benchmark()
flags_core.define_performance(
num_parallel_calls=False, inter_op=True, intra_op=True,
synthetic_data=False, max_train_steps=False, dtype=False,
... | python | def define_wide_deep_flags():
"""Add supervised learning flags, as well as wide-deep model type."""
flags_core.define_base()
flags_core.define_benchmark()
flags_core.define_performance(
num_parallel_calls=False, inter_op=True, intra_op=True,
synthetic_data=False, max_train_steps=False, dtype=False,
... | [
"def",
"define_wide_deep_flags",
"(",
")",
":",
"flags_core",
".",
"define_base",
"(",
")",
"flags_core",
".",
"define_benchmark",
"(",
")",
"flags_core",
".",
"define_performance",
"(",
"num_parallel_calls",
"=",
"False",
",",
"inter_op",
"=",
"True",
",",
"int... | Add supervised learning flags, as well as wide-deep model type. | [
"Add",
"supervised",
"learning",
"flags",
"as",
"well",
"as",
"wide",
"-",
"deep",
"model",
"type",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/wide_deep_run_loop.py#L37-L54 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/wide_deep_run_loop.py | export_model | def export_model(model, model_type, export_dir, model_column_fn):
"""Export to SavedModel format.
Args:
model: Estimator object
model_type: string indicating model type. "wide", "deep" or "wide_deep"
export_dir: directory to export the model.
model_column_fn: Function to generate model feature colu... | python | def export_model(model, model_type, export_dir, model_column_fn):
"""Export to SavedModel format.
Args:
model: Estimator object
model_type: string indicating model type. "wide", "deep" or "wide_deep"
export_dir: directory to export the model.
model_column_fn: Function to generate model feature colu... | [
"def",
"export_model",
"(",
"model",
",",
"model_type",
",",
"export_dir",
",",
"model_column_fn",
")",
":",
"wide_columns",
",",
"deep_columns",
"=",
"model_column_fn",
"(",
")",
"if",
"model_type",
"==",
"'wide'",
":",
"columns",
"=",
"wide_columns",
"elif",
... | Export to SavedModel format.
Args:
model: Estimator object
model_type: string indicating model type. "wide", "deep" or "wide_deep"
export_dir: directory to export the model.
model_column_fn: Function to generate model feature columns. | [
"Export",
"to",
"SavedModel",
"format",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/wide_deep_run_loop.py#L57-L77 | train |
yahoo/TensorFlowOnSpark | examples/wide_deep/wide_deep_run_loop.py | run_loop | def run_loop(name, train_input_fn, eval_input_fn, model_column_fn,
build_estimator_fn, flags_obj, tensors_to_log, early_stop=False):
"""Define training loop."""
model_helpers.apply_clean(flags.FLAGS)
model = build_estimator_fn(
model_dir=flags_obj.model_dir, model_type=flags_obj.model_type,
... | python | def run_loop(name, train_input_fn, eval_input_fn, model_column_fn,
build_estimator_fn, flags_obj, tensors_to_log, early_stop=False):
"""Define training loop."""
model_helpers.apply_clean(flags.FLAGS)
model = build_estimator_fn(
model_dir=flags_obj.model_dir, model_type=flags_obj.model_type,
... | [
"def",
"run_loop",
"(",
"name",
",",
"train_input_fn",
",",
"eval_input_fn",
",",
"model_column_fn",
",",
"build_estimator_fn",
",",
"flags_obj",
",",
"tensors_to_log",
",",
"early_stop",
"=",
"False",
")",
":",
"model_helpers",
".",
"apply_clean",
"(",
"flags",
... | Define training loop. | [
"Define",
"training",
"loop",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/wide_deep/wide_deep_run_loop.py#L80-L131 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_train.py | _tower_loss | def _tower_loss(images, labels, num_classes, scope, reuse_variables=None):
"""Calculate the total loss on a single tower running the ImageNet model.
We perform 'batch splitting'. This means that we cut up a batch across
multiple GPU's. For instance, if the batch size = 32 and num_gpus = 2,
then each tower will... | python | def _tower_loss(images, labels, num_classes, scope, reuse_variables=None):
"""Calculate the total loss on a single tower running the ImageNet model.
We perform 'batch splitting'. This means that we cut up a batch across
multiple GPU's. For instance, if the batch size = 32 and num_gpus = 2,
then each tower will... | [
"def",
"_tower_loss",
"(",
"images",
",",
"labels",
",",
"num_classes",
",",
"scope",
",",
"reuse_variables",
"=",
"None",
")",
":",
"# When fine-tuning a model, we do not restore the logits but instead we",
"# randomly initialize the logits. The number of classes in the output of ... | Calculate the total loss on a single tower running the ImageNet model.
We perform 'batch splitting'. This means that we cut up a batch across
multiple GPU's. For instance, if the batch size = 32 and num_gpus = 2,
then each tower will operate on an batch of 16 images.
Args:
images: Images. 4D tensor of siz... | [
"Calculate",
"the",
"total",
"loss",
"on",
"a",
"single",
"tower",
"running",
"the",
"ImageNet",
"model",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_train.py#L82-L140 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/inception_train.py | train | def train(dataset):
"""Train on dataset for a number of steps."""
with tf.Graph().as_default(), tf.device('/cpu:0'):
# Create a variable to count the number of train() calls. This equals the
# number of batches processed * FLAGS.num_gpus.
global_step = tf.get_variable(
'global_step', [],
... | python | def train(dataset):
"""Train on dataset for a number of steps."""
with tf.Graph().as_default(), tf.device('/cpu:0'):
# Create a variable to count the number of train() calls. This equals the
# number of batches processed * FLAGS.num_gpus.
global_step = tf.get_variable(
'global_step', [],
... | [
"def",
"train",
"(",
"dataset",
")",
":",
"with",
"tf",
".",
"Graph",
"(",
")",
".",
"as_default",
"(",
")",
",",
"tf",
".",
"device",
"(",
"'/cpu:0'",
")",
":",
"# Create a variable to count the number of train() calls. This equals the",
"# number of batches proces... | Train on dataset for a number of steps. | [
"Train",
"on",
"dataset",
"for",
"a",
"number",
"of",
"steps",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/inception_train.py#L181-L357 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | batch_norm | def batch_norm(inputs,
decay=0.999,
center=True,
scale=False,
epsilon=0.001,
moving_vars='moving_vars',
activation=None,
is_training=True,
trainable=True,
restore=True,
s... | python | def batch_norm(inputs,
decay=0.999,
center=True,
scale=False,
epsilon=0.001,
moving_vars='moving_vars',
activation=None,
is_training=True,
trainable=True,
restore=True,
s... | [
"def",
"batch_norm",
"(",
"inputs",
",",
"decay",
"=",
"0.999",
",",
"center",
"=",
"True",
",",
"scale",
"=",
"False",
",",
"epsilon",
"=",
"0.001",
",",
"moving_vars",
"=",
"'moving_vars'",
",",
"activation",
"=",
"None",
",",
"is_training",
"=",
"True... | Adds a Batch Normalization layer.
Args:
inputs: a tensor of size [batch_size, height, width, channels]
or [batch_size, channels].
decay: decay for the moving average.
center: If True, subtract beta. If False, beta is not created and ignored.
scale: If True, multiply by gamma. If False, ga... | [
"Adds",
"a",
"Batch",
"Normalization",
"layer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L43-L132 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | _two_element_tuple | def _two_element_tuple(int_or_tuple):
"""Converts `int_or_tuple` to height, width.
Several of the functions that follow accept arguments as either
a tuple of 2 integers or a single integer. A single integer
indicates that the 2 values of the tuple are the same.
This functions normalizes the input value by ... | python | def _two_element_tuple(int_or_tuple):
"""Converts `int_or_tuple` to height, width.
Several of the functions that follow accept arguments as either
a tuple of 2 integers or a single integer. A single integer
indicates that the 2 values of the tuple are the same.
This functions normalizes the input value by ... | [
"def",
"_two_element_tuple",
"(",
"int_or_tuple",
")",
":",
"if",
"isinstance",
"(",
"int_or_tuple",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"if",
"len",
"(",
"int_or_tuple",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Must be a list with 2 ele... | Converts `int_or_tuple` to height, width.
Several of the functions that follow accept arguments as either
a tuple of 2 integers or a single integer. A single integer
indicates that the 2 values of the tuple are the same.
This functions normalizes the input value by always returning a tuple.
Args:
int_... | [
"Converts",
"int_or_tuple",
"to",
"height",
"width",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L135-L163 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | conv2d | def conv2d(inputs,
num_filters_out,
kernel_size,
stride=1,
padding='SAME',
activation=tf.nn.relu,
stddev=0.01,
bias=0.0,
weight_decay=0,
batch_norm_params=None,
is_training=True,
trainable=True,
... | python | def conv2d(inputs,
num_filters_out,
kernel_size,
stride=1,
padding='SAME',
activation=tf.nn.relu,
stddev=0.01,
bias=0.0,
weight_decay=0,
batch_norm_params=None,
is_training=True,
trainable=True,
... | [
"def",
"conv2d",
"(",
"inputs",
",",
"num_filters_out",
",",
"kernel_size",
",",
"stride",
"=",
"1",
",",
"padding",
"=",
"'SAME'",
",",
"activation",
"=",
"tf",
".",
"nn",
".",
"relu",
",",
"stddev",
"=",
"0.01",
",",
"bias",
"=",
"0.0",
",",
"weigh... | Adds a 2D convolution followed by an optional batch_norm layer.
conv2d creates a variable called 'weights', representing the convolutional
kernel, that is convolved with the input. If `batch_norm_params` is None, a
second variable called 'biases' is added to the result of the convolution
operation.
Args:
... | [
"Adds",
"a",
"2D",
"convolution",
"followed",
"by",
"an",
"optional",
"batch_norm",
"layer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L167-L246 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | fc | def fc(inputs,
num_units_out,
activation=tf.nn.relu,
stddev=0.01,
bias=0.0,
weight_decay=0,
batch_norm_params=None,
is_training=True,
trainable=True,
restore=True,
scope=None,
reuse=None):
"""Adds a fully connected layer followed by an optio... | python | def fc(inputs,
num_units_out,
activation=tf.nn.relu,
stddev=0.01,
bias=0.0,
weight_decay=0,
batch_norm_params=None,
is_training=True,
trainable=True,
restore=True,
scope=None,
reuse=None):
"""Adds a fully connected layer followed by an optio... | [
"def",
"fc",
"(",
"inputs",
",",
"num_units_out",
",",
"activation",
"=",
"tf",
".",
"nn",
".",
"relu",
",",
"stddev",
"=",
"0.01",
",",
"bias",
"=",
"0.0",
",",
"weight_decay",
"=",
"0",
",",
"batch_norm_params",
"=",
"None",
",",
"is_training",
"=",
... | Adds a fully connected layer followed by an optional batch_norm layer.
FC creates a variable called 'weights', representing the fully connected
weight matrix, that is multiplied by the input. If `batch_norm` is None, a
second variable called 'biases' is added to the result of the initial
vector-matrix multipli... | [
"Adds",
"a",
"fully",
"connected",
"layer",
"followed",
"by",
"an",
"optional",
"batch_norm",
"layer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L250-L317 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | one_hot_encoding | def one_hot_encoding(labels, num_classes, scope=None):
"""Transform numeric labels into onehot_labels.
Args:
labels: [batch_size] target labels.
num_classes: total number of classes.
scope: Optional scope for name_scope.
Returns:
one hot encoding of the labels.
"""
with tf.name_scope(scope, '... | python | def one_hot_encoding(labels, num_classes, scope=None):
"""Transform numeric labels into onehot_labels.
Args:
labels: [batch_size] target labels.
num_classes: total number of classes.
scope: Optional scope for name_scope.
Returns:
one hot encoding of the labels.
"""
with tf.name_scope(scope, '... | [
"def",
"one_hot_encoding",
"(",
"labels",
",",
"num_classes",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'OneHotEncoding'",
",",
"[",
"labels",
"]",
")",
":",
"batch_size",
"=",
"labels",
".",
"get_shape",
"... | Transform numeric labels into onehot_labels.
Args:
labels: [batch_size] target labels.
num_classes: total number of classes.
scope: Optional scope for name_scope.
Returns:
one hot encoding of the labels. | [
"Transform",
"numeric",
"labels",
"into",
"onehot_labels",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L320-L338 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | max_pool | def max_pool(inputs, kernel_size, stride=2, padding='VALID', scope=None):
"""Adds a Max Pooling layer.
It is assumed by the wrapper that the pooling is only done per image and not
in depth or batch.
Args:
inputs: a tensor of size [batch_size, height, width, depth].
kernel_size: a list of length 2: [ke... | python | def max_pool(inputs, kernel_size, stride=2, padding='VALID', scope=None):
"""Adds a Max Pooling layer.
It is assumed by the wrapper that the pooling is only done per image and not
in depth or batch.
Args:
inputs: a tensor of size [batch_size, height, width, depth].
kernel_size: a list of length 2: [ke... | [
"def",
"max_pool",
"(",
"inputs",
",",
"kernel_size",
",",
"stride",
"=",
"2",
",",
"padding",
"=",
"'VALID'",
",",
"scope",
"=",
"None",
")",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'MaxPool'",
",",
"[",
"inputs",
"]",
")",
":",
... | Adds a Max Pooling layer.
It is assumed by the wrapper that the pooling is only done per image and not
in depth or batch.
Args:
inputs: a tensor of size [batch_size, height, width, depth].
kernel_size: a list of length 2: [kernel_height, kernel_width] of the
pooling kernel over which the op is com... | [
"Adds",
"a",
"Max",
"Pooling",
"layer",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L342-L370 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | dropout | def dropout(inputs, keep_prob=0.5, is_training=True, scope=None):
"""Returns a dropout layer applied to the input.
Args:
inputs: the tensor to pass to the Dropout layer.
keep_prob: the probability of keeping each input unit.
is_training: whether or not the model is in training mode. If so, dropout is
... | python | def dropout(inputs, keep_prob=0.5, is_training=True, scope=None):
"""Returns a dropout layer applied to the input.
Args:
inputs: the tensor to pass to the Dropout layer.
keep_prob: the probability of keeping each input unit.
is_training: whether or not the model is in training mode. If so, dropout is
... | [
"def",
"dropout",
"(",
"inputs",
",",
"keep_prob",
"=",
"0.5",
",",
"is_training",
"=",
"True",
",",
"scope",
"=",
"None",
")",
":",
"if",
"is_training",
"and",
"keep_prob",
">",
"0",
":",
"with",
"tf",
".",
"name_scope",
"(",
"scope",
",",
"'Dropout'"... | Returns a dropout layer applied to the input.
Args:
inputs: the tensor to pass to the Dropout layer.
keep_prob: the probability of keeping each input unit.
is_training: whether or not the model is in training mode. If so, dropout is
applied and values scaled. Otherwise, inputs is returned.
scope:... | [
"Returns",
"a",
"dropout",
"layer",
"applied",
"to",
"the",
"input",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L404-L421 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | flatten | def flatten(inputs, scope=None):
"""Flattens the input while maintaining the batch_size.
Assumes that the first dimension represents the batch.
Args:
inputs: a tensor of size [batch_size, ...].
scope: Optional scope for name_scope.
Returns:
a flattened tensor with shape [batch_size, k].
Raise... | python | def flatten(inputs, scope=None):
"""Flattens the input while maintaining the batch_size.
Assumes that the first dimension represents the batch.
Args:
inputs: a tensor of size [batch_size, ...].
scope: Optional scope for name_scope.
Returns:
a flattened tensor with shape [batch_size, k].
Raise... | [
"def",
"flatten",
"(",
"inputs",
",",
"scope",
"=",
"None",
")",
":",
"if",
"len",
"(",
"inputs",
".",
"get_shape",
"(",
")",
")",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'Inputs must be have a least 2 dimensions'",
")",
"dims",
"=",
"inputs",
".",
"... | Flattens the input while maintaining the batch_size.
Assumes that the first dimension represents the batch.
Args:
inputs: a tensor of size [batch_size, ...].
scope: Optional scope for name_scope.
Returns:
a flattened tensor with shape [batch_size, k].
Raises:
ValueError: if inputs.shape is ... | [
"Flattens",
"the",
"input",
"while",
"maintaining",
"the",
"batch_size",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L424-L443 | train |
yahoo/TensorFlowOnSpark | examples/imagenet/inception/slim/ops.py | repeat_op | def repeat_op(repetitions, inputs, op, *args, **kwargs):
"""Build a sequential Tower starting from inputs by using an op repeatedly.
It creates new scopes for each operation by increasing the counter.
Example: given repeat_op(3, _, ops.conv2d, 64, [3, 3], scope='conv1')
it will repeat the given op under the ... | python | def repeat_op(repetitions, inputs, op, *args, **kwargs):
"""Build a sequential Tower starting from inputs by using an op repeatedly.
It creates new scopes for each operation by increasing the counter.
Example: given repeat_op(3, _, ops.conv2d, 64, [3, 3], scope='conv1')
it will repeat the given op under the ... | [
"def",
"repeat_op",
"(",
"repetitions",
",",
"inputs",
",",
"op",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"scope",
"=",
"kwargs",
".",
"pop",
"(",
"'scope'",
",",
"None",
")",
"with",
"tf",
".",
"variable_scope",
"(",
"scope",
",",
"'R... | Build a sequential Tower starting from inputs by using an op repeatedly.
It creates new scopes for each operation by increasing the counter.
Example: given repeat_op(3, _, ops.conv2d, 64, [3, 3], scope='conv1')
it will repeat the given op under the following variable_scopes:
conv1/Conv
conv1/Conv_1... | [
"Build",
"a",
"sequential",
"Tower",
"starting",
"from",
"inputs",
"by",
"using",
"an",
"op",
"repeatedly",
"."
] | 5e4b6c185ab722fd0104ede0377e1149ea8d6f7c | https://github.com/yahoo/TensorFlowOnSpark/blob/5e4b6c185ab722fd0104ede0377e1149ea8d6f7c/examples/imagenet/inception/slim/ops.py#L446-L473 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc_manager.py | RPCManager.do_rpc | def do_rpc(self, name: str, rpc_function: Callable[..., Awaitable[None]]) -> Callable[..., Awaitable[None]]:
"""
Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio
event loop. The wrapped function catches all unhandled exceptions and reports them to t... | python | def do_rpc(self, name: str, rpc_function: Callable[..., Awaitable[None]]) -> Callable[..., Awaitable[None]]:
"""
Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio
event loop. The wrapped function catches all unhandled exceptions and reports them to t... | [
"def",
"do_rpc",
"(",
"self",
",",
"name",
":",
"str",
",",
"rpc_function",
":",
"Callable",
"[",
"...",
",",
"Awaitable",
"[",
"None",
"]",
"]",
")",
"->",
"Callable",
"[",
"...",
",",
"Awaitable",
"[",
"None",
"]",
"]",
":",
"async",
"def",
"rpc_... | Wraps a given RPC function by producing an awaitable function suitable to be run in the asyncio
event loop. The wrapped function catches all unhandled exceptions and reports them to the exception
future, which consumers can await upon to listen for unhandled exceptions.
The wrapped function als... | [
"Wraps",
"a",
"given",
"RPC",
"function",
"by",
"producing",
"an",
"awaitable",
"function",
"suitable",
"to",
"be",
"run",
"in",
"the",
"asyncio",
"event",
"loop",
".",
"The",
"wrapped",
"function",
"catches",
"all",
"unhandled",
"exceptions",
"and",
"reports"... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc_manager.py#L49-L87 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/resource.py | register_resource | def register_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inputs', opts: Optional['ResourceOptions']):
"""
registerResource registers a new resource object with a given type t and name. It returns the auto-generated
URN and the ID that will resolve after the deployment has completed.... | python | def register_resource(res: 'Resource', ty: str, name: str, custom: bool, props: 'Inputs', opts: Optional['ResourceOptions']):
"""
registerResource registers a new resource object with a given type t and name. It returns the auto-generated
URN and the ID that will resolve after the deployment has completed.... | [
"def",
"register_resource",
"(",
"res",
":",
"'Resource'",
",",
"ty",
":",
"str",
",",
"name",
":",
"str",
",",
"custom",
":",
"bool",
",",
"props",
":",
"'Inputs'",
",",
"opts",
":",
"Optional",
"[",
"'ResourceOptions'",
"]",
")",
":",
"log",
".",
"... | registerResource registers a new resource object with a given type t and name. It returns the auto-generated
URN and the ID that will resolve after the deployment has completed. All properties will be initialized to property
objects that the registration operation will resolve at the right time (or remain unr... | [
"registerResource",
"registers",
"a",
"new",
"resource",
"object",
"with",
"a",
"given",
"type",
"t",
"and",
"name",
".",
"It",
"returns",
"the",
"auto",
"-",
"generated",
"URN",
"and",
"the",
"ID",
"that",
"will",
"resolve",
"after",
"the",
"deployment",
... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/resource.py#L123-L234 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/settings.py | configure | def configure(settings: Settings):
"""
Configure sets the current ambient settings bag to the one given.
"""
if not settings or not isinstance(settings, Settings):
raise TypeError('Settings is expected to be non-None and of type Settings')
global SETTINGS # pylint: disable=global-statement
... | python | def configure(settings: Settings):
"""
Configure sets the current ambient settings bag to the one given.
"""
if not settings or not isinstance(settings, Settings):
raise TypeError('Settings is expected to be non-None and of type Settings')
global SETTINGS # pylint: disable=global-statement
... | [
"def",
"configure",
"(",
"settings",
":",
"Settings",
")",
":",
"if",
"not",
"settings",
"or",
"not",
"isinstance",
"(",
"settings",
",",
"Settings",
")",
":",
"raise",
"TypeError",
"(",
"'Settings is expected to be non-None and of type Settings'",
")",
"global",
... | Configure sets the current ambient settings bag to the one given. | [
"Configure",
"sets",
"the",
"current",
"ambient",
"settings",
"bag",
"to",
"the",
"one",
"given",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/settings.py#L70-L77 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/settings.py | get_project | def get_project() -> Optional[str]:
"""
Returns the current project name.
"""
project = SETTINGS.project
if not project:
require_test_mode_enabled()
raise RunError('Missing project name; for test mode, please set PULUMI_NODEJS_PROJECT')
return project | python | def get_project() -> Optional[str]:
"""
Returns the current project name.
"""
project = SETTINGS.project
if not project:
require_test_mode_enabled()
raise RunError('Missing project name; for test mode, please set PULUMI_NODEJS_PROJECT')
return project | [
"def",
"get_project",
"(",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"project",
"=",
"SETTINGS",
".",
"project",
"if",
"not",
"project",
":",
"require_test_mode_enabled",
"(",
")",
"raise",
"RunError",
"(",
"'Missing project name; for test mode, please set PULUMI... | Returns the current project name. | [
"Returns",
"the",
"current",
"project",
"name",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/settings.py#L107-L115 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/settings.py | get_stack | def get_stack() -> Optional[str]:
"""
Returns the current stack name.
"""
stack = SETTINGS.stack
if not stack:
require_test_mode_enabled()
raise RunError('Missing stack name; for test mode, please set PULUMI_NODEJS_STACK')
return stack | python | def get_stack() -> Optional[str]:
"""
Returns the current stack name.
"""
stack = SETTINGS.stack
if not stack:
require_test_mode_enabled()
raise RunError('Missing stack name; for test mode, please set PULUMI_NODEJS_STACK')
return stack | [
"def",
"get_stack",
"(",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"stack",
"=",
"SETTINGS",
".",
"stack",
"if",
"not",
"stack",
":",
"require_test_mode_enabled",
"(",
")",
"raise",
"RunError",
"(",
"'Missing stack name; for test mode, please set PULUMI_NODEJS_ST... | Returns the current stack name. | [
"Returns",
"the",
"current",
"stack",
"name",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/settings.py#L125-L133 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/settings.py | get_monitor | def get_monitor() -> Optional[resource_pb2_grpc.ResourceMonitorStub]:
"""
Returns the current resource monitoring service client for RPC communications.
"""
monitor = SETTINGS.monitor
if not monitor:
require_test_mode_enabled()
return monitor | python | def get_monitor() -> Optional[resource_pb2_grpc.ResourceMonitorStub]:
"""
Returns the current resource monitoring service client for RPC communications.
"""
monitor = SETTINGS.monitor
if not monitor:
require_test_mode_enabled()
return monitor | [
"def",
"get_monitor",
"(",
")",
"->",
"Optional",
"[",
"resource_pb2_grpc",
".",
"ResourceMonitorStub",
"]",
":",
"monitor",
"=",
"SETTINGS",
".",
"monitor",
"if",
"not",
"monitor",
":",
"require_test_mode_enabled",
"(",
")",
"return",
"monitor"
] | Returns the current resource monitoring service client for RPC communications. | [
"Returns",
"the",
"current",
"resource",
"monitoring",
"service",
"client",
"for",
"RPC",
"communications",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/settings.py#L143-L150 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | serialize_properties | async def serialize_properties(inputs: 'Inputs',
property_deps: Dict[str, List['Resource']],
input_transformer: Optional[Callable[[str], str]] = None) -> struct_pb2.Struct:
"""
Serializes an arbitrary Input bag into a Protobuf structure, keeping trac... | python | async def serialize_properties(inputs: 'Inputs',
property_deps: Dict[str, List['Resource']],
input_transformer: Optional[Callable[[str], str]] = None) -> struct_pb2.Struct:
"""
Serializes an arbitrary Input bag into a Protobuf structure, keeping trac... | [
"async",
"def",
"serialize_properties",
"(",
"inputs",
":",
"'Inputs'",
",",
"property_deps",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"'Resource'",
"]",
"]",
",",
"input_transformer",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"str",
"]",
",",
"str",
... | Serializes an arbitrary Input bag into a Protobuf structure, keeping track of the list
of dependent resources in the `deps` list. Serializing properties is inherently async
because it awaits any futures that are contained transitively within the input bag. | [
"Serializes",
"an",
"arbitrary",
"Input",
"bag",
"into",
"a",
"Protobuf",
"structure",
"keeping",
"track",
"of",
"the",
"list",
"of",
"dependent",
"resources",
"in",
"the",
"deps",
"list",
".",
"Serializing",
"properties",
"is",
"inherently",
"async",
"because",... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L46-L70 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | serialize_property | async def serialize_property(value: 'Input[Any]',
deps: List['Resource'],
input_transformer: Optional[Callable[[str], str]] = None) -> Any:
"""
Serializes a single Input into a form suitable for remoting to the engine, awaiting
any futures required t... | python | async def serialize_property(value: 'Input[Any]',
deps: List['Resource'],
input_transformer: Optional[Callable[[str], str]] = None) -> Any:
"""
Serializes a single Input into a form suitable for remoting to the engine, awaiting
any futures required t... | [
"async",
"def",
"serialize_property",
"(",
"value",
":",
"'Input[Any]'",
",",
"deps",
":",
"List",
"[",
"'Resource'",
"]",
",",
"input_transformer",
":",
"Optional",
"[",
"Callable",
"[",
"[",
"str",
"]",
",",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"... | Serializes a single Input into a form suitable for remoting to the engine, awaiting
any futures required to do so. | [
"Serializes",
"a",
"single",
"Input",
"into",
"a",
"form",
"suitable",
"for",
"remoting",
"to",
"the",
"engine",
"awaiting",
"any",
"futures",
"required",
"to",
"do",
"so",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L74-L159 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | deserialize_properties | def deserialize_properties(props_struct: struct_pb2.Struct) -> Any:
"""
Deserializes a protobuf `struct_pb2.Struct` into a Python dictionary containing normal
Python types.
"""
# Check out this link for details on what sort of types Protobuf is going to generate:
# https://developers.google.com/... | python | def deserialize_properties(props_struct: struct_pb2.Struct) -> Any:
"""
Deserializes a protobuf `struct_pb2.Struct` into a Python dictionary containing normal
Python types.
"""
# Check out this link for details on what sort of types Protobuf is going to generate:
# https://developers.google.com/... | [
"def",
"deserialize_properties",
"(",
"props_struct",
":",
"struct_pb2",
".",
"Struct",
")",
"->",
"Any",
":",
"# Check out this link for details on what sort of types Protobuf is going to generate:",
"# https://developers.google.com/protocol-buffers/docs/reference/python-generated",
"#"... | Deserializes a protobuf `struct_pb2.Struct` into a Python dictionary containing normal
Python types. | [
"Deserializes",
"a",
"protobuf",
"struct_pb2",
".",
"Struct",
"into",
"a",
"Python",
"dictionary",
"containing",
"normal",
"Python",
"types",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L162-L203 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | deserialize_property | def deserialize_property(value: Any) -> Any:
"""
Deserializes a single protobuf value (either `Struct` or `ListValue`) into idiomatic
Python values.
"""
if value == UNKNOWN:
return None
# ListValues are projected to lists
if isinstance(value, struct_pb2.ListValue):
return [d... | python | def deserialize_property(value: Any) -> Any:
"""
Deserializes a single protobuf value (either `Struct` or `ListValue`) into idiomatic
Python values.
"""
if value == UNKNOWN:
return None
# ListValues are projected to lists
if isinstance(value, struct_pb2.ListValue):
return [d... | [
"def",
"deserialize_property",
"(",
"value",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"value",
"==",
"UNKNOWN",
":",
"return",
"None",
"# ListValues are projected to lists",
"if",
"isinstance",
"(",
"value",
",",
"struct_pb2",
".",
"ListValue",
")",
":",
"retu... | Deserializes a single protobuf value (either `Struct` or `ListValue`) into idiomatic
Python values. | [
"Deserializes",
"a",
"single",
"protobuf",
"value",
"(",
"either",
"Struct",
"or",
"ListValue",
")",
"into",
"idiomatic",
"Python",
"values",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L206-L223 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | translate_output_properties | def translate_output_properties(res: 'Resource', output: Any) -> Any:
"""
Recursively rewrite keys of objects returned by the engine to conform with a naming
convention specified by the resource's implementation of `translate_output_property`.
If output is a `dict`, every key is translated using `trans... | python | def translate_output_properties(res: 'Resource', output: Any) -> Any:
"""
Recursively rewrite keys of objects returned by the engine to conform with a naming
convention specified by the resource's implementation of `translate_output_property`.
If output is a `dict`, every key is translated using `trans... | [
"def",
"translate_output_properties",
"(",
"res",
":",
"'Resource'",
",",
"output",
":",
"Any",
")",
"->",
"Any",
":",
"if",
"isinstance",
"(",
"output",
",",
"dict",
")",
":",
"return",
"{",
"res",
".",
"translate_output_property",
"(",
"k",
")",
":",
"... | Recursively rewrite keys of objects returned by the engine to conform with a naming
convention specified by the resource's implementation of `translate_output_property`.
If output is a `dict`, every key is translated using `translate_output_property` while every value is transformed
by recursing.
If o... | [
"Recursively",
"rewrite",
"keys",
"of",
"objects",
"returned",
"by",
"the",
"engine",
"to",
"conform",
"with",
"a",
"naming",
"convention",
"specified",
"by",
"the",
"resource",
"s",
"implementation",
"of",
"translate_output_property",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L274-L292 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/rpc.py | resolve_outputs_due_to_exception | def resolve_outputs_due_to_exception(resolvers: Dict[str, Resolver], exn: Exception):
"""
Resolves all outputs with resolvers exceptionally, using the given exception as the reason why the resolver has
failed to resolve.
:param resolvers: Resolvers associated with a resource's outputs.
:param exn: ... | python | def resolve_outputs_due_to_exception(resolvers: Dict[str, Resolver], exn: Exception):
"""
Resolves all outputs with resolvers exceptionally, using the given exception as the reason why the resolver has
failed to resolve.
:param resolvers: Resolvers associated with a resource's outputs.
:param exn: ... | [
"def",
"resolve_outputs_due_to_exception",
"(",
"resolvers",
":",
"Dict",
"[",
"str",
",",
"Resolver",
"]",
",",
"exn",
":",
"Exception",
")",
":",
"for",
"key",
",",
"resolve",
"in",
"resolvers",
".",
"items",
"(",
")",
":",
"log",
".",
"debug",
"(",
... | Resolves all outputs with resolvers exceptionally, using the given exception as the reason why the resolver has
failed to resolve.
:param resolvers: Resolvers associated with a resource's outputs.
:param exn: The exception that occured when trying (and failing) to create this resource. | [
"Resolves",
"all",
"outputs",
"with",
"resolvers",
"exceptionally",
"using",
"the",
"given",
"exception",
"as",
"the",
"reason",
"why",
"the",
"resolver",
"has",
"failed",
"to",
"resolve",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/rpc.py#L363-L373 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.get | def get(self, key: str) -> Optional[str]:
"""
Returns an optional configuration value by its key, or None if it doesn't exist.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exist.
:rtype: Optional[str]
""... | python | def get(self, key: str) -> Optional[str]:
"""
Returns an optional configuration value by its key, or None if it doesn't exist.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exist.
:rtype: Optional[str]
""... | [
"def",
"get",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"return",
"get_config",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
")"
] | Returns an optional configuration value by its key, or None if it doesn't exist.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exist.
:rtype: Optional[str] | [
"Returns",
"an",
"optional",
"configuration",
"value",
"by",
"its",
"key",
"or",
"None",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L50-L58 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.get_bool | def get_bool(self, key: str) -> Optional[bool]:
"""
Returns an optional configuration value, as a bool, by its key, or None if it doesn't exist.
If the configuration value isn't a legal boolean, this function will throw an error.
:param str key: The requested configuration key.
... | python | def get_bool(self, key: str) -> Optional[bool]:
"""
Returns an optional configuration value, as a bool, by its key, or None if it doesn't exist.
If the configuration value isn't a legal boolean, this function will throw an error.
:param str key: The requested configuration key.
... | [
"def",
"get_bool",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"if",
"v",
"in",
"[",
"'true'",
",",
"'True'",
... | Returns an optional configuration value, as a bool, by its key, or None if it doesn't exist.
If the configuration value isn't a legal boolean, this function will throw an error.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exis... | [
"Returns",
"an",
"optional",
"configuration",
"value",
"as",
"a",
"bool",
"by",
"its",
"key",
"or",
"None",
"if",
"it",
"doesn",
"t",
"exist",
".",
"If",
"the",
"configuration",
"value",
"isn",
"t",
"a",
"legal",
"boolean",
"this",
"function",
"will",
"t... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L60-L77 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.get_int | def get_int(self, key: str) -> Optional[int]:
"""
Returns an optional configuration value, as an int, by its key, or None if it doesn't exist.
If the configuration value isn't a legal int, this function will throw an error.
:param str key: The requested configuration key.
:retur... | python | def get_int(self, key: str) -> Optional[int]:
"""
Returns an optional configuration value, as an int, by its key, or None if it doesn't exist.
If the configuration value isn't a legal int, this function will throw an error.
:param str key: The requested configuration key.
:retur... | [
"def",
"get_int",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"int",
"(",
"v",
")",
"ex... | Returns an optional configuration value, as an int, by its key, or None if it doesn't exist.
If the configuration value isn't a legal int, this function will throw an error.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exist.
... | [
"Returns",
"an",
"optional",
"configuration",
"value",
"as",
"an",
"int",
"by",
"its",
"key",
"or",
"None",
"if",
"it",
"doesn",
"t",
"exist",
".",
"If",
"the",
"configuration",
"value",
"isn",
"t",
"a",
"legal",
"int",
"this",
"function",
"will",
"throw... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L79-L95 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.get_float | def get_float(self, key: str) -> Optional[float]:
"""
Returns an optional configuration value, as a float, by its key, or None if it doesn't exist.
If the configuration value isn't a legal float, this function will throw an error.
:param str key: The requested configuration key.
... | python | def get_float(self, key: str) -> Optional[float]:
"""
Returns an optional configuration value, as a float, by its key, or None if it doesn't exist.
If the configuration value isn't a legal float, this function will throw an error.
:param str key: The requested configuration key.
... | [
"def",
"get_float",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"Optional",
"[",
"float",
"]",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"float",
"(",
"v",
")",... | Returns an optional configuration value, as a float, by its key, or None if it doesn't exist.
If the configuration value isn't a legal float, this function will throw an error.
:param str key: The requested configuration key.
:return: The configuration key's value, or None if one does not exist... | [
"Returns",
"an",
"optional",
"configuration",
"value",
"as",
"a",
"float",
"by",
"its",
"key",
"or",
"None",
"if",
"it",
"doesn",
"t",
"exist",
".",
"If",
"the",
"configuration",
"value",
"isn",
"t",
"a",
"legal",
"float",
"this",
"function",
"will",
"th... | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L97-L113 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.require | def require(self, key: str) -> str:
"""
Returns a configuration value by its given key. If it doesn't exist, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: str
:raises ConfigMissingError: The configur... | python | def require(self, key: str) -> str:
"""
Returns a configuration value by its given key. If it doesn't exist, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: str
:raises ConfigMissingError: The configur... | [
"def",
"require",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"str",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ConfigMissingError",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
")",
"return"... | Returns a configuration value by its given key. If it doesn't exist, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: str
:raises ConfigMissingError: The configuration value did not exist. | [
"Returns",
"a",
"configuration",
"value",
"by",
"its",
"given",
"key",
".",
"If",
"it",
"doesn",
"t",
"exist",
"an",
"error",
"is",
"thrown",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L115-L127 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.require_bool | def require_bool(self, key: str) -> bool:
"""
Returns a configuration value, as a bool, by its given key. If it doesn't exist, or the
configuration value is not a legal bool, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's v... | python | def require_bool(self, key: str) -> bool:
"""
Returns a configuration value, as a bool, by its given key. If it doesn't exist, or the
configuration value is not a legal bool, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's v... | [
"def",
"require_bool",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"bool",
":",
"v",
"=",
"self",
".",
"get_bool",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ConfigMissingError",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
")",... | Returns a configuration value, as a bool, by its given key. If it doesn't exist, or the
configuration value is not a legal bool, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: bool
:raises ConfigMissingError:... | [
"Returns",
"a",
"configuration",
"value",
"as",
"a",
"bool",
"by",
"its",
"given",
"key",
".",
"If",
"it",
"doesn",
"t",
"exist",
"or",
"the",
"configuration",
"value",
"is",
"not",
"a",
"legal",
"bool",
"an",
"error",
"is",
"thrown",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L129-L143 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.require_int | def require_int(self, key: str) -> int:
"""
Returns a configuration value, as an int, by its given key. If it doesn't exist, or the
configuration value is not a legal int, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's valu... | python | def require_int(self, key: str) -> int:
"""
Returns a configuration value, as an int, by its given key. If it doesn't exist, or the
configuration value is not a legal int, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's valu... | [
"def",
"require_int",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"int",
":",
"v",
"=",
"self",
".",
"get_int",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ConfigMissingError",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
")",
... | Returns a configuration value, as an int, by its given key. If it doesn't exist, or the
configuration value is not a legal int, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: int
:raises ConfigMissingError: T... | [
"Returns",
"a",
"configuration",
"value",
"as",
"an",
"int",
"by",
"its",
"given",
"key",
".",
"If",
"it",
"doesn",
"t",
"exist",
"or",
"the",
"configuration",
"value",
"is",
"not",
"a",
"legal",
"int",
"an",
"error",
"is",
"thrown",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L145-L159 | train |
pulumi/pulumi | sdk/python/lib/pulumi/config.py | Config.require_float | def require_float(self, key: str) -> float:
"""
Returns a configuration value, as a float, by its given key. If it doesn't exist, or the
configuration value is not a legal number, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration ke... | python | def require_float(self, key: str) -> float:
"""
Returns a configuration value, as a float, by its given key. If it doesn't exist, or the
configuration value is not a legal number, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration ke... | [
"def",
"require_float",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"float",
":",
"v",
"=",
"self",
".",
"get_float",
"(",
"key",
")",
"if",
"v",
"is",
"None",
":",
"raise",
"ConfigMissingError",
"(",
"self",
".",
"full_key",
"(",
"key",
")",
"... | Returns a configuration value, as a float, by its given key. If it doesn't exist, or the
configuration value is not a legal number, an error is thrown.
:param str key: The requested configuration key.
:return: The configuration key's value.
:rtype: float
:raises ConfigMissingEr... | [
"Returns",
"a",
"configuration",
"value",
"as",
"a",
"float",
"by",
"its",
"given",
"key",
".",
"If",
"it",
"doesn",
"t",
"exist",
"or",
"the",
"configuration",
"value",
"is",
"not",
"a",
"legal",
"number",
"an",
"error",
"is",
"thrown",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/config.py#L161-L175 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/known_types.py | asset | def asset(class_obj: type) -> type:
"""
Decorator to annotate the Asset class. Registers the decorated class
as the Asset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _asset_resource_type
_asset_resource_type = class_obj
return class_obj | python | def asset(class_obj: type) -> type:
"""
Decorator to annotate the Asset class. Registers the decorated class
as the Asset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _asset_resource_type
_asset_resource_type = class_obj
return class_obj | [
"def",
"asset",
"(",
"class_obj",
":",
"type",
")",
"->",
"type",
":",
"assert",
"isinstance",
"(",
"class_obj",
",",
"type",
")",
",",
"\"class_obj is not a Class\"",
"global",
"_asset_resource_type",
"_asset_resource_type",
"=",
"class_obj",
"return",
"class_obj"
... | Decorator to annotate the Asset class. Registers the decorated class
as the Asset known type. | [
"Decorator",
"to",
"annotate",
"the",
"Asset",
"class",
".",
"Registers",
"the",
"decorated",
"class",
"as",
"the",
"Asset",
"known",
"type",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/known_types.py#L66-L74 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/known_types.py | file_asset | def file_asset(class_obj: type) -> type:
"""
Decorator to annotate the FileAsset class. Registers the decorated class
as the FileAsset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _file_asset_resource_type
_file_asset_resource_type = class_obj
ret... | python | def file_asset(class_obj: type) -> type:
"""
Decorator to annotate the FileAsset class. Registers the decorated class
as the FileAsset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _file_asset_resource_type
_file_asset_resource_type = class_obj
ret... | [
"def",
"file_asset",
"(",
"class_obj",
":",
"type",
")",
"->",
"type",
":",
"assert",
"isinstance",
"(",
"class_obj",
",",
"type",
")",
",",
"\"class_obj is not a Class\"",
"global",
"_file_asset_resource_type",
"_file_asset_resource_type",
"=",
"class_obj",
"return",... | Decorator to annotate the FileAsset class. Registers the decorated class
as the FileAsset known type. | [
"Decorator",
"to",
"annotate",
"the",
"FileAsset",
"class",
".",
"Registers",
"the",
"decorated",
"class",
"as",
"the",
"FileAsset",
"known",
"type",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/known_types.py#L77-L85 | train |
pulumi/pulumi | sdk/python/lib/pulumi/runtime/known_types.py | string_asset | def string_asset(class_obj: type) -> type:
"""
Decorator to annotate the StringAsset class. Registers the decorated class
as the StringAsset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _string_asset_resource_type
_string_asset_resource_type = class_o... | python | def string_asset(class_obj: type) -> type:
"""
Decorator to annotate the StringAsset class. Registers the decorated class
as the StringAsset known type.
"""
assert isinstance(class_obj, type), "class_obj is not a Class"
global _string_asset_resource_type
_string_asset_resource_type = class_o... | [
"def",
"string_asset",
"(",
"class_obj",
":",
"type",
")",
"->",
"type",
":",
"assert",
"isinstance",
"(",
"class_obj",
",",
"type",
")",
",",
"\"class_obj is not a Class\"",
"global",
"_string_asset_resource_type",
"_string_asset_resource_type",
"=",
"class_obj",
"re... | Decorator to annotate the StringAsset class. Registers the decorated class
as the StringAsset known type. | [
"Decorator",
"to",
"annotate",
"the",
"StringAsset",
"class",
".",
"Registers",
"the",
"decorated",
"class",
"as",
"the",
"StringAsset",
"known",
"type",
"."
] | 95d51efe6ab9a533838b6d83aa240b5f912e72aa | https://github.com/pulumi/pulumi/blob/95d51efe6ab9a533838b6d83aa240b5f912e72aa/sdk/python/lib/pulumi/runtime/known_types.py#L88-L96 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.