(x)
| 74 | input_shape=(10,)) |
| 75 | |
| 76 | def train_step(x): |
| 77 | with backprop.GradientTape() as tape: |
| 78 | model(x) |
| 79 | assert len(model.losses) == 2 |
| 80 | loss = math_ops.reduce_sum(model.losses) |
| 81 | gradients = tape.gradient(loss, model.trainable_weights) |
| 82 | optimizer.apply_gradients(zip(gradients, model.trainable_weights)) |
| 83 | return loss |
| 84 | |
| 85 | if defun: |
| 86 | train_step = def_function.function(train_step) |
no test coverage detected