tf.contrib.framework.smart_case
Stay organized with collections
Save and categorize content based on your preferences.
Like tf.case, except attempts to statically evaluate predicates.
tf.contrib.framework.smart_case(
pred_fn_pairs, default=None, exclusive=False, name='smart_case'
)
If any predicate in pred_fn_pairs
is a bool or has a constant value, the
associated callable will be called or omitted depending on its value.
Otherwise this functions like tf.case.
Args |
pred_fn_pairs
|
Dict or list of pairs of a boolean scalar tensor and a
callable which returns a list of tensors.
|
default
|
Optional callable that returns a list of tensors.
|
exclusive
|
True iff at most one predicate is allowed to evaluate to True .
|
name
|
A name for this operation (optional).
|
Returns |
The tensors returned by the first pair whose predicate evaluated to True, or
those returned by default if none does.
|
Raises |
TypeError
|
If pred_fn_pairs is not a list/dictionary.
|
TypeError
|
If pred_fn_pairs is a list but does not contain 2-tuples.
|
TypeError
|
If fns[i] is not callable for any i, or default is not
callable.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[null,null,["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.framework.smart_case\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/python/framework/smart_cond.py#L93-L119) |\n\nLike tf.case, except attempts to statically evaluate predicates. \n\n tf.contrib.framework.smart_case(\n pred_fn_pairs, default=None, exclusive=False, name='smart_case'\n )\n\nIf any predicate in `pred_fn_pairs` is a bool or has a constant value, the\nassociated callable will be called or omitted depending on its value.\nOtherwise this functions like tf.case.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-----------------|--------------------------------------------------------------------------------------------------|\n| `pred_fn_pairs` | Dict or list of pairs of a boolean scalar tensor and a callable which returns a list of tensors. |\n| `default` | Optional callable that returns a list of tensors. |\n| `exclusive` | True iff at most one predicate is allowed to evaluate to `True`. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The tensors returned by the first pair whose predicate evaluated to True, or those returned by `default` if none does. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|----------------------------------------------------------------------|\n| `TypeError` | If `pred_fn_pairs` is not a list/dictionary. |\n| `TypeError` | If `pred_fn_pairs` is a list but does not contain 2-tuples. |\n| `TypeError` | If `fns[i]` is not callable for any i, or `default` is not callable. |\n\n\u003cbr /\u003e"]]