pub fn random<R: Rng>(num_items: usize, rng: &mut R) -> Self {
        Hyperparameters {
            num_items,
            max_sequence_length: 2_usize.pow(Uniform::new(4, 8).sample(rng)),
            item_embedding_dim: 2_usize.pow(Uniform::new(4, 8).sample(rng)),
            learning_rate: (10.0_f32).powf(Uniform::new(-3.0, 0.5).sample(rng)),
            l2_penalty: (10.0_f32).powf(Uniform::new(-7.0, -3.0).sample(rng)),
            loss: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Loss::BPR
            } else {
                Loss::Hinge
            },
            optimizer: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Optimizer::Adam
            } else {
                Optimizer::Adagrad
            },
            lstm_type: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                LSTMVariant::Normal
            } else {
                LSTMVariant::Coupled
            },
            parallelism: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Parallelism::Asynchronous
            } else {
                Parallelism::Synchronous
            },
            rng: XorShiftRng::from_seed(rand::thread_rng().gen()),
            num_threads: Uniform::new(1, rayon::current_num_threads() + 1).sample(rng),
            num_epochs: 2_usize.pow(Uniform::new(3, 7).sample(rng)),
        }
    }
/// Set hyperparameters randomly: useful for hyperparameter search.
Set hyperparameters randomly: useful for hyperparameter search.
Set hyperparameters randomly : useful for hyperparameter search .
pub fn random<R: Rng>(num_items: usize, rng: &mut R) -> Self {
        Hyperparameters {
            num_items,
            max_sequence_length: 2_usize.pow(Uniform::new(4, 8).sample(rng)),
            item_embedding_dim: 2_usize.pow(Uniform::new(4, 8).sample(rng)),
            learning_rate: (10.0_f32).powf(Uniform::new(-3.0, 0.5).sample(rng)),
            l2_penalty: (10.0_f32).powf(Uniform::new(-7.0, -3.0).sample(rng)),
            loss: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Loss::BPR
            } else {
                Loss::Hinge
            },
            optimizer: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Optimizer::Adam
            } else {
                Optimizer::Adagrad
            },
            lstm_type: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                LSTMVariant::Normal
            } else {
                LSTMVariant::Coupled
            },
            parallelism: if Uniform::new(0.0, 1.0).sample(rng) < 0.5 {
                Parallelism::Asynchronous
            } else {
                Parallelism::Synchronous
            },
            rng: XorShiftRng::from_seed(rand::thread_rng().gen()),
            num_threads: Uniform::new(1, rayon::current_num_threads() + 1).sample(rng),
            num_epochs: 2_usize.pow(Uniform::new(3, 7).sample(rng)),
        }
    }
pub fn random < R : Rng > ( num_items : usize , rng : & mut R ) -> Self { Hyperparameters { num_items , max_sequence_length : 2_usize . pow ( Uniform :: new ( 4 , 8 ) . sample ( rng ) ) , item_embedding_dim : 2_usize . pow ( Uniform :: new ( 4 , 8 ) . sample ( rng ) ) , learning_rate : ( 10.0_f32 ) . powf ( Uniform :: new ( - 3.0 , 0.5 ) . sample ( rng ) ) , l2_penalty : ( 10.0_f32 ) . powf ( Uniform :: new ( - 7.0 , - 3.0 ) . sample ( rng ) ) , loss : if Uniform :: new ( 0.0 , 1.0 ) . sample ( rng ) < 0.5 { Loss :: BPR } else { Loss :: Hinge } , optimizer : if Uniform :: new ( 0.0 , 1.0 ) . sample ( rng ) < 0.5 { Optimizer :: Adam } else { Optimizer :: Adagrad } , lstm_type : if Uniform :: new ( 0.0 , 1.0 ) . sample ( rng ) < 0.5 { LSTMVariant :: Normal } else { LSTMVariant :: Coupled } , parallelism : if Uniform :: new ( 0.0 , 1.0 ) . sample ( rng ) < 0.5 { Parallelism :: Asynchronous } else { Parallelism :: Synchronous } , rng : XorShiftRng :: from_seed ( rand :: thread_rng ( ) . gen ( ) ) , num_threads : Uniform :: new ( 1 , rayon :: current_num_threads ( ) + 1 ) . sample ( rng ) , num_epochs : 2_usize . pow ( Uniform :: new ( 3 , 7 ) . sample ( rng ) ) , } }
Set hyperparameters randomly: useful for hyperparameter search.
Set hyperparameters randomly : useful for hyperparameter search .
num_items
usize
rng
&mut R