Creates a NetBuilder that will execute once as the next step of the current NetBuilder if the blob `cond` is True. Example: with ops.If(ops.Const(True)): ops.Print(ops.Const('Will print')) with ops.If(ops.Const(False)):
(self, cond, name=None)
| 321 | _StopGuard(has_stopped_blob=has_stopped_blob, name=name)) |
| 322 | |
| 323 | def If(self, cond, name=None): |
| 324 | """ |
| 325 | Creates a NetBuilder that will execute once as the next step of the |
| 326 | current NetBuilder if the blob `cond` is True. |
| 327 | Example: |
| 328 | with ops.If(ops.Const(True)): |
| 329 | ops.Print(ops.Const('Will print')) |
| 330 | with ops.If(ops.Const(False)): |
| 331 | ops.Print(ops.Const('Wont print')) |
| 332 | The example will print 'Will print' once. |
| 333 | """ |
| 334 | return NetBuilder.current().add(_RunIf(cond, name=name)) |
| 335 | |
| 336 | def IfNet(self, cond, name=None): |
| 337 | """ |