hzwer / ICCV2019-LearningToPaint

ICCV2019 - Learning to Paint With Model-based Deep Reinforcement Learning
MIT License
2.25k stars 312 forks source link

hard_update #48

Closed patrisaru closed 3 years ago

patrisaru commented 3 years ago

Hello :)

Could you tell me why is necessary this function and what it do exactly?

def hard_update(target, source): for m1, m2 in zip(target.modules(), source.modules()): m1._buffers = m2._buffers.copy() for target_param, param in zip(target.parameters(), source.parameters()): targetparam.data.copy(param.data)

I do not understand! Thanks so much!

hzwer commented 3 years ago

Hello :) This function copies a model to another model, including parameters and the statistic value buffers of BatchNorm.

patrisaru commented 3 years ago

But why do you call this function at ddpg.py ? why is necessary? when and why do you use hard_update() in your algorithm? Thanks so much for your answer :)

hzwer commented 3 years ago

It's not necessary, it's just used to ensure actor and actor_target have same parameters in the beginning of training.