Closed udion closed 6 years ago
Hi,
The last gen_cost = -gen_cost
does not affect the gradients or the optimizer_g.step() because after backward(), gradients are calculated. It only affects the graph when we draw the gen_cost (It just flips vertically when you're putting - or not putting -)
What matters here is:
gen_cost.backward(mone)
and
disc_cost = disc_fake - disc_real + gradient_penalty
disc_cost.backward()
After optimizer.step()
, G tries to maximize gen_cost and D tries to minimize disc_fake(kind of gen_cost). So there is a fight between G and D.
yes thank you. Tell me though are these 2 equivalent:
gen_cost = -gen_cost
and then gen_cost.backward()
gen_cost
before calling backward
and instead pass mone
in backward (i.e what you did)thanks too,
That's true
gen_cost = -gen_cost
gen_cost.backward()
would result the same.
The issue is solved.
Hi, In the gan training code, since you have already used
gen_cost.backward(mone)
for generator, why are you still doinggen_cost = -gen_cost
i.e, should it not be
gen_cost.backward(mone)
orgen_cost.backward()
and thengen_cost = gen_cost*-1
Please correct me if I am wrong.