r"""output = Cond(inputs) ? then_branch(inputs) : else_branch(inputs). Args: cond: A `Tensor`. A scalar. If the scalar is not a boolean, the scalar is converted to a boolean according to the following rule: if the scalar is a numerical value, non-zero means True and zero mean
(cond, inputs, then_branch, else_branch, name=None)
| 531 | |
| 532 | # pylint: disable=invalid-name |
| 533 | def If(cond, inputs, then_branch, else_branch, name=None): |
| 534 | r"""output = Cond(inputs) ? |
| 535 | |
| 536 | then_branch(inputs) : else_branch(inputs). |
| 537 | |
| 538 | Args: |
| 539 | cond: A `Tensor`. A scalar. If the scalar is not a boolean, the scalar is |
| 540 | converted to a boolean according to the following rule: if the scalar is a |
| 541 | numerical value, non-zero means True and zero means False; if the scalar |
| 542 | is a string, non-empty means True and empty means False. |
| 543 | inputs: A list of input tensors. |
| 544 | then_branch: A function takes 'inputs' and returns a list of tensors, whose |
| 545 | types are the same as what else_branch returns. |
| 546 | else_branch: A function takes 'inputs' and returns a list of tensors. whose |
| 547 | types are the same as what then_branch returns. |
| 548 | name: A name for the operation (optional). |
| 549 | |
| 550 | Returns: |
| 551 | A list of tensors returned by either then_branch(inputs) |
| 552 | or else_branch(inputs). |
| 553 | """ |
| 554 | # pylint: disable=protected-access |
| 555 | return gen_functional_ops._if( |
| 556 | cond, |
| 557 | inputs, [_.type for _ in then_branch.definition.signature.output_arg], |
| 558 | then_branch, |
| 559 | else_branch, |
| 560 | name=name) |
| 561 | |
| 562 | |
| 563 | def Gradient(inputs, f, name=None): |