Created
March 16, 2019 07:13
-
-
Save AFAgarap/c64dd6571ab5ba6d3f74eed9483e4b3a to your computer and use it in GitHub Desktop.
Optimization function for a vanilla autoencoder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def train(loss, model, opt, original): | |
with tf.GradientTape() as tape: | |
gradients = tape.gradient(loss(model, original), model.trainable_variables) | |
gradient_variables = zip(gradients, model.trainable_variables) | |
opt.apply_gradients(gradient_variables) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment