mirror of
https://github.com/Magnus167/rustframe.git
synced 2025-08-20 04:00:01 +00:00
Refactor random number generation to use rustframe's random module
This commit is contained in:
parent
4a1843183a
commit
5934b163f5
@ -5,8 +5,8 @@
|
||||
//! To modify the behaviour of the example, please change the constants at the top of this file.
|
||||
//! By default,
|
||||
|
||||
use rand::{self, Rng};
|
||||
use rustframe::matrix::{BoolMatrix, BoolOps, IntMatrix, Matrix};
|
||||
use rustframe::random::{rng, Rng};
|
||||
use std::{thread, time};
|
||||
|
||||
const BOARD_SIZE: usize = 20; // Size of the board (50x50)
|
||||
@ -265,7 +265,7 @@ pub fn generate_glider(board: &mut BoolMatrix, board_size: usize) {
|
||||
// Initialize with a Glider pattern.
|
||||
// It demonstrates how to set specific cells in the matrix.
|
||||
// This demonstrates `IndexMut` for `current_board[(r, c)] = true;`.
|
||||
let mut rng = rand::rng();
|
||||
let mut rng = rng();
|
||||
let r_offset = rng.random_range(0..(board_size - 3));
|
||||
let c_offset = rng.random_range(0..(board_size - 3));
|
||||
if board.rows() >= r_offset + 3 && board.cols() >= c_offset + 3 {
|
||||
@ -281,7 +281,7 @@ pub fn generate_pulsar(board: &mut BoolMatrix, board_size: usize) {
|
||||
// Initialize with a Pulsar pattern.
|
||||
// This demonstrates how to set specific cells in the matrix.
|
||||
// This demonstrates `IndexMut` for `current_board[(r, c)] = true;`.
|
||||
let mut rng = rand::rng();
|
||||
let mut rng = rng();
|
||||
let r_offset = rng.random_range(0..(board_size - 17));
|
||||
let c_offset = rng.random_range(0..(board_size - 17));
|
||||
if board.rows() >= r_offset + 17 && board.cols() >= c_offset + 17 {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::compute::models::activations::{drelu, relu, sigmoid};
|
||||
use crate::matrix::{Matrix, SeriesOps};
|
||||
use rand::prelude::*;
|
||||
use crate::random::prelude::*;
|
||||
|
||||
/// Supported activation functions
|
||||
#[derive(Clone)]
|
||||
@ -46,7 +46,7 @@ pub enum InitializerKind {
|
||||
|
||||
impl InitializerKind {
|
||||
pub fn initialize(&self, rows: usize, cols: usize) -> Matrix<f64> {
|
||||
let mut rng = rand::rng();
|
||||
let mut rng = rng();
|
||||
let fan_in = rows;
|
||||
let fan_out = cols;
|
||||
let limit = match self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user