MCPcopy
hub / github.com/tensorlayer/TensorLayer / train_step

Function train_step

examples/basic_tutorials/tutorial_mnist_siamese.py:104–113  ·  view source on GitHub ↗
(X_batch, y_batch)

Source from the content-addressed store, hash-verified

102
103@tf.function
104def train_step(X_batch, y_batch):
105 with tf.GradientTape() as tape:
106 _out1, _out2 = model([X_batch[:, 0, :], X_batch[:, 1, :]])
107 _loss = contrastive_loss(y_batch, _out1, _out2)
108
109 grad = tape.gradient(_loss, train_weights)
110 optimizer.apply_gradients(zip(grad, train_weights))
111
112 _acc = compute_accuracy(y_batch, _out1, _out2)
113 return _loss, _acc
114
115
116# begin training

Callers 1

Calls 4

contrastive_lossFunction · 0.85
compute_accuracyFunction · 0.85
gradientMethod · 0.80
modelFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…