1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
use rand::{Rng, thread_rng}; use fast_io::CustomIO; use std::fmt::Debug; use super::connection::Connection; pub trait Neuron: Clone+Debug+PartialEq+CustomIO { type C: Connection+Sized; fn new(prev_layer_size: usize) -> Self; fn bias(&self) -> f64; fn output(&self) -> f64; fn set_output(&mut self, output: f64); fn connections(&mut self) -> &mut Vec<Self::C>; } pub fn rand_weight() -> f64 { thread_rng().gen_range(-0.33, 0.33) }