Skip to content

Instantly share code, notes, and snippets.

@emrectn
Created April 5, 2020 12:53
Show Gist options
  • Select an option

  • Save emrectn/ec03e058a3db08cd4bd0465fc1a7b197 to your computer and use it in GitHub Desktop.

Select an option

Save emrectn/ec03e058a3db08cd4bd0465fc1a7b197 to your computer and use it in GitHub Desktop.

Revisions

  1. emrectn created this gist Apr 5, 2020.
    6 changes: 6 additions & 0 deletions compute_grads.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    def compute_grads(cfg):
    with tf.GradientTape() as tape:
    all_loss = compute_loss(**cfg)
    # Compute gradients wrt input image
    total_loss = all_loss[0]
    return tape.gradient(total_loss, cfg['init_image']), all_loss