autonomousvision / giraffe

This repository contains the code for the CVPR 2021 paper "GIRAFFE: Representing Scenes as Compositional Generative Neural Feature Fields"
https://m-niemeyer.github.io/project-pages/giraffe/index.html
MIT License
1.24k stars 160 forks source link

why the input images requires grad? #44

Closed xxxmian closed 2 years ago

xxxmian commented 2 years ago

hi, i have a question in im2scene/giraffe/training.py, in function train_step_discriminator(),line 152 (x_real.requiresgrad())and line 168(x_fake.requiresgrad()). Does this mean that x_real(from Dataset) and x_fake(from generator) will be optimized over and over again during training, but why optimize these two variables?What are the deep ideas in this?

WechatIMG317
m-niemeyer commented 2 years ago

Hi @xxxmian , no, that's not the case (because we do not update the images). This step is done do get the gradients such that we are able to calculate the R2 gradient penalty which is performed here.