pub struct NNUE { /* private fields */ }Expand description
NNUE (Efficiently Updatable Neural Network) for chess position evaluation This implementation is designed to work alongside vector-based position analysis
The key innovation is that NNUE provides fast, accurate position evaluation while the vector-based system provides strategic pattern recognition and similarity matching. Together they create a hybrid system that’s both fast and strategically aware.
Implementations§
Source§impl NNUE
impl NNUE
Sourcepub fn new(config: NNUEConfig) -> CandleResult<Self>
pub fn new(config: NNUEConfig) -> CandleResult<Self>
Create a new NNUE evaluator with vector integration
Sourcepub fn new_with_weights(
config: NNUEConfig,
weights: Option<HashMap<String, Tensor>>,
) -> CandleResult<Self>
pub fn new_with_weights( config: NNUEConfig, weights: Option<HashMap<String, Tensor>>, ) -> CandleResult<Self>
Create NNUE with optional pre-loaded weights
Sourcepub fn evaluate(&mut self, board: &Board) -> CandleResult<f32>
pub fn evaluate(&mut self, board: &Board) -> CandleResult<f32>
Evaluate a position using NNUE
Sourcepub fn evaluate_hybrid(
&mut self,
board: &Board,
vector_eval: Option<f32>,
) -> CandleResult<f32>
pub fn evaluate_hybrid( &mut self, board: &Board, vector_eval: Option<f32>, ) -> CandleResult<f32>
Hybrid evaluation combining NNUE with vector-based analysis
Sourcepub fn train_batch(&mut self, positions: &[(Board, f32)]) -> CandleResult<f32>
pub fn train_batch(&mut self, positions: &[(Board, f32)]) -> CandleResult<f32>
Train the NNUE network on position data
Sourcepub fn update_incrementally(
&mut self,
board: &Board,
_chess_move: ChessMove,
) -> CandleResult<()>
pub fn update_incrementally( &mut self, board: &Board, _chess_move: ChessMove, ) -> CandleResult<()>
Incremental update when a move is made (NNUE efficiency feature)
Sourcepub fn set_vector_weight(&mut self, weight: f32)
pub fn set_vector_weight(&mut self, weight: f32)
Set the vector evaluation blend weight
Sourcepub fn are_weights_loaded(&self) -> bool
pub fn are_weights_loaded(&self) -> bool
Check if weights were loaded from file
Sourcepub fn quick_fix_training(
&mut self,
positions: &[(Board, f32)],
) -> CandleResult<f32>
pub fn quick_fix_training( &mut self, positions: &[(Board, f32)], ) -> CandleResult<f32>
Quick training to fix evaluation issues when weights weren’t properly applied
Sourcepub fn incremental_train(
&mut self,
positions: &[(Board, f32)],
preserve_best: bool,
) -> CandleResult<f32>
pub fn incremental_train( &mut self, positions: &[(Board, f32)], preserve_best: bool, ) -> CandleResult<f32>
Incremental training that preserves existing progress
Sourcepub fn set_vector_integration(&mut self, enabled: bool)
pub fn set_vector_integration(&mut self, enabled: bool)
Enable or disable vector integration
Sourcepub fn get_config(&self) -> NNUEConfig
pub fn get_config(&self) -> NNUEConfig
Get current configuration
Sourcepub fn save_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>
pub fn save_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>
Save the trained model to a file with full weight serialization
Sourcepub fn load_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>
pub fn load_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>
Load a trained model from a file with full weight restoration
Sourcepub fn recreate_with_loaded_weights(
&mut self,
weights: HashMap<String, Tensor>,
) -> CandleResult<()>
pub fn recreate_with_loaded_weights( &mut self, weights: HashMap<String, Tensor>, ) -> CandleResult<()>
Recreate the NNUE with loaded weights (workaround for candle-nn limitations)
Sourcepub fn get_eval_stats(&mut self, positions: &[Board]) -> CandleResult<EvalStats>
pub fn get_eval_stats(&mut self, positions: &[Board]) -> CandleResult<EvalStats>
Get evaluation statistics for analysis
Auto Trait Implementations§
impl Freeze for NNUE
impl !RefUnwindSafe for NNUE
impl Send for NNUE
impl Sync for NNUE
impl Unpin for NNUE
impl !UnwindSafe for NNUE
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more