MCPcopy Create free account
hub / github.com/tensorflow/models / train_on_batch

Method train_on_batch

official/benchmark/tf_scan_benchmark.py:77–82  ·  view source on GitHub ↗
(self, *args)

Source from the content-addressed store, hash-verified

75
76 @tf.function
77 def train_on_batch(self, *args):
78 with tf.GradientTape(persistent=True) as tape:
79 loss = self._loss(*args)
80 grads = tape.gradient(loss, self.trainable_weights)
81 self.optimizer.apply_gradients(zip(grads, self.trainable_variables))
82 return loss
83
84 def train(self, epochs, batch_size, num_batches):
85 data_generator_iter = gen_batches(num_batches, batch_size, self.units)

Callers 1

trainMethod · 0.95

Calls 2

_lossMethod · 0.95
apply_gradientsMethod · 0.45

Tested by

no test coverage detected