UndefVarError: `Random` not defined

I tried to use the function with Random as below:

init_params = Float64.(ComponentArray(Lux.setup(Random.default_rng(), chain)[1]))

and I got the message: UndefVarError: `Random` not defined. Please help me to fix it.
Thank you all.

Random isn’t in Base, you have to import it, with import Random or using Random. It’s in the standard library, though, so you don’t need to install anything new.

2 Likes