goiter / CoCPC

49 stars 17 forks source link

shallow copy #2

Open lingjieyi opened 2 years ago

lingjieyi commented 2 years ago

line 80 of the model.py file:

def regenerate_data(self, x, t, y, adj_p):
    data = x

data = x is the show copy, then in the line 90, data[b, -pred_terms:, :] = x[rand_num, -pred_terms:, :], both x and data changes simultaneously

Is it still "draws a result from a distribution that excludes itself"

lingjieyi commented 2 years ago

also, line 90, why to use

data[b, -pred_terms:, :] = x[rand_num, -pred_terms:, :]

instead of

data[b, pred_terms:, :] = x[rand_num, pred_terms:, :]

goiter commented 2 years ago

Yes, it is a shallow copy but we only need the 'data', after line 90, the 'x' will not be used again, so I think it is ok.

about your second question, here we use '-pred_terms' to get the training data.