MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / train_step

Function train_step

tensorflow/python/keras/custom_training_loop_test.py:76–83  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

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)

Calls 6

modelFunction · 0.85
reduce_sumMethod · 0.80
gradientMethod · 0.80
GradientTapeMethod · 0.45
apply_gradientsMethod · 0.45
resultMethod · 0.45

Tested by

no test coverage detected