For loop implementation.
tf.keras.ops.fori_loop(
lower, upper, body_fun, init_val
)
| Args | |
|---|---|
lower | The initial value of the loop variable. |
upper | The upper bound of the loop variable. |
body_fun | A callable that represents the loop body. Must take two arguments: the loop variable and the loop state. The loop state should be updated and returned by this function. |
init_val | The initial value of the loop state. |
| Returns | |
|---|---|
| The final state after the loop. |
lower = 0 upper = 10 body_fun = lambda i, s: (i + 1, s + i) init_val = 0 keras.ops.fori_loop(lower, upper, body_fun, init_val) 45
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/keras/ops/fori_loop