Skip to content

Random seeds #1

@kwalcock

Description

@kwalcock

Instead of this code

np.random.seed(i)
np.random.shuffle(trainX)
np.random.seed(i)           # make sure to reset seed again to keep labels and data together!
np.random.shuffle(trainY)

you might try something more like

rng_state = np.random.get_state()
np.random.shuffle(trainX)
np.random.set_state(rng_state)
np.random.shuffle(trainY)

It's unfortunate that the numpy shuffle routine doesn't take a random generator as an argument so that two different generators can be used in parallel. The new code rewinds the single generator to the old state between sorts. This might be more random than sampling the initial values of consecutive sequences and it won't mess up randomization elsewhere in the code if the reseed is not expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions