Hi Nick!



 Nick_8229:

Currently I am generated normal random number by the following,
‘’’
zn = torch.FloatTensor(dim1, dim2)
zn.normal_()
‘’’
I am wondering how could i set seed for each tensor?


manual_seed() should work, e.g.:
zn1 = torch.FloatTensor(dim1, dim2)
zn2 = torch.FloatTensor(dim1, dim2)
zn3 = torch.FloatTensor(dim1, dim2)

torch.manual_seed (seed1)
zn1.normal_()
torch.manual_seed (seed2)
zn2.normal_()
torch.manual_seed (seed3)
zn3.normal_()

Is this what you were asking?
Bear in mind, though, that you don’t generally want to do this.
You are probably better off letting pytorch’s (pseudo) random
number generator do its thing, rather than potentially making
it less random (at the margins – probably won’t matter in
practice) by injecting new seeds all the time.
My typical use of setting the random-number seed is to make
some overall run repeatable from run to run, so that, for example,
my random network weights start out as the same random weights
for each run.  But I wouldn’t use different seeds, for example, for
the weights in different layers.
Good luck.
K. Frank