This chapter covers
- Generating (pseudo) random numbers in JAX
- Differences with NumPy and using keys to represent pseudo-random number generator state
- Working with keys and generating random numbers in real-life applications
Working with randomness is essential, as many machine learning algorithms use stochasticity in some way. Randomness is used to make random splits and samplings from the data, generate random data, and perform random augmentations. It is also required for for specific neural network–related algorithms like Dropout or architectures like variational auto-encoders (VAE) or generative adversarial networks (GANs) and in hyperparameter tuning to search for better hyperparameter values. Randomness is also essential to the process that is at the heart of deep learning: weight initialization. Surely randomness is no less important in other fields outside of machine learning. Random numbers are at the heart of Monte Carlo simulations and statistical sampling and have many applications in computer simulation of real-world processes.