Removing Initialization Randomness
- If the random module is used for random initialization in the code, you need to call random.seed to set a fixed random seed before the random initialization. You are advised to directly use a fixed value for initialization.
- If the NumPy random initialization is used in the code, for example, random initialization, you need to call the numpy.random.seed function to set a fixed random seed before the initialization. You are advised to directly use a fixed value for initialization, for example, use the numpy.full function to fill in a fixed value.
- If the TensorFlow random initialization is used in the code, for example, tf.truncated_normal_initializer, you need to call the tf.set_random_seed(TF1) or tf.random.set_seed(TF2) function to set a fixed random seed before the initialization. You are advised to directly use a fixed value for initialization, for example, use the tf.constant_initializer function to fill in a fixed value.
- If a pre-trained model is loaded for initialization in the code, ensure that the same pre-trained model is loaded on different devices or during multiple runs.
- Other random initializations are also removed or modified in a deterministic manner.
Parent topic: Removing Fixed Randomness