CR-Gjx / LeakGAN

The codes of paper "Long Text Generation via Adversarial Training with Leaked Information" on AAAI 2018. Text generation using GAN and Hierarchical Reinforcement Learning.
https://arxiv.org/abs/1709.08624
577 stars 181 forks source link

I think the Bootstrapped Rescaled Activation in the code is not useful #20

Open 3015218116 opened 5 years ago

3015218116 commented 5 years ago

def rescale( reward, rollout_num=1.0): reward = np.array(reward) x, y = reward.shape ret = np.zeros((x, y)) for i in range(x): l = reward[i] rescalar = {} for s in l: rescalar[s] = s idxx = 1 min_s = 1.0 max_s = 0.0 for s in rescalar: rescalar[s] = redistribution(idxx, len(l), min_s) idxx += 1 for j in range(y): ret[i, j] = rescalar[reward[i, j]] return ret

I read the code, but I didn't see any sorting behavior, more like scaling by insertion order. If this code is collating, "for s in rescalar," it might be more reasonable to read it in some sort order. Please advise, thank you very much.

desire2020 commented 5 years ago

The sorting operation is hidden behind the the implementation of the Python ``map'' object. As it is implemented by a binary search tree, which automatically sort the inserted elements, the operation to iterate through its key element (for s in rescalar, if you may notice) would result in a ordered visit of them. Hope this note helps.

joonazan commented 4 years ago

@desire2020 That is not true. dict keys are iterated over in a random order.

Kljon commented 4 years ago

I have the same question. dict keys are iterated over in random order. Is it have any explanation?