Property setter for Dataset

I am trying to change a property of my Dataset. However the value is not updated when using workers. What do I need to do to allow dynamic update of variables when using workers to load data via DataLoader?

Example:

ImageDataset(torch.utils.data.Dataset):
_variance = 1.0

@property
def i(self):
    return type(self)._variance

@i.setter
def i(self, val):
    type(self)._variance = val

From the training loop:
ImageDataset._variance = 0.5

Do you need to update your Datasetduring an epoch or would it be sufficient to update it after each one?
In the latter case, have a look at this example.

I would like to update the parameters for each mini-batch, parameter update after each epoch doesn’t solve my issue.

Could this be implemented in the __getitem__ using some logic or do you need to pass the new value from outside?
In the latter case, you could try to adapt this shared arrays approach.

Yes I need to update this from the training loop i.e. outside, the shared arrays approach looks good.