baselines icon indicating copy to clipboard operation
baselines copied to clipboard

Major Bug in a2c implementation

Open crazymuse opened this issue 9 years ago • 2 comments

Discounting of rewards should be for elements before done, not for ones after it. It seems like this is a major error in implementation

Correct way G_{t} = R_{t} + gamma*(R_{t+1}) V_{t} ---> G_{t}

Current Way G_{t} = R_{t} + gamma*(R_{t-1}) V_{t} ---> G_{t}

File utils.py code for discount_with_dones is as follow :


def discount_with_dones(rewards, dones, gamma):
    discounted = []
    r = 0
    for reward, done in zip(rewards[::-1], dones[::-1]):
        print ('actual rewards in discount',reward)
        print ('looping rewards in discount',r)
        print ('Done in discount in discount',done)
        r = reward + gamma*r*(1.-done) # fixed off by one bug
        discounted.append(r)
    return discounted[::-1]

Please let me know, if there is something I have missed . Do comment on my current understanding, irrespective of it being correct or incorrect.

crazymuse avatar Nov 29 '17 14:11 crazymuse

Please respond on the raised bug ticket . . .

crazymuse avatar Nov 30 '17 08:11 crazymuse

I missed ' ::-1' , that it means reversed state.

crazymuse avatar Nov 30 '17 12:11 crazymuse