Struct NNUE

Source
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

Source

pub fn new(config: NNUEConfig) -> CandleResult<Self>

Create a new NNUE evaluator with vector integration

Source

pub fn new_with_weights( config: NNUEConfig, weights: Option<HashMap<String, Tensor>>, ) -> CandleResult<Self>

Create NNUE with optional pre-loaded weights

Source

pub fn evaluate(&mut self, board: &Board) -> CandleResult<f32>

Evaluate a position using NNUE

Source

pub fn evaluate_optimized(&mut self, board: &Board) -> CandleResult<f32>

Ultra-fast NNUE evaluation with real incremental updates

Source

pub fn update_after_move( &mut self, chess_move: ChessMove, board_before: &Board, board_after: &Board, ) -> CandleResult<()>

Update NNUE after a move is made (incremental update)

Source

pub fn evaluate_batch(&mut self, boards: &[Board]) -> CandleResult<Vec<f32>>

Batch evaluation for multiple positions (efficient for analysis)

Source

pub fn evaluate_from_features(&mut self, features: &Tensor) -> CandleResult<f32>

Fast evaluation using pre-computed feature vectors

Source

pub fn evaluate_hybrid( &mut self, board: &Board, vector_eval: Option<f32>, tactical_eval: Option<f32>, ) -> CandleResult<f32>

Advanced hybrid evaluation combining NNUE with vector-based analysis

Source

pub fn benchmark_performance( &mut self, positions: &[Board], iterations: usize, ) -> Result<NNUEBenchmarkResult, Box<dyn Error>>

Performance benchmark for NNUE evaluation

Source§

impl NNUE

Source

pub fn train_batch(&mut self, positions: &[(Board, f32)]) -> CandleResult<f32>

Train the NNUE network on position data

Source

pub fn update_incrementally( &mut self, board: &Board, _chess_move: ChessMove, ) -> CandleResult<()>

Incremental update when a move is made (NNUE efficiency feature)

Source

pub fn set_vector_weight(&mut self, weight: f32)

Set the vector evaluation blend weight

Source

pub fn are_weights_loaded(&self) -> bool

Check if weights were loaded from file

Source

pub fn quick_fix_training( &mut self, positions: &[(Board, f32)], ) -> CandleResult<f32>

Quick training to fix evaluation issues when weights weren’t properly applied

Source

pub fn incremental_train( &mut self, positions: &[(Board, f32)], preserve_best: bool, ) -> CandleResult<f32>

Incremental training that preserves existing progress

Source

pub fn set_vector_integration(&mut self, enabled: bool)

Enable or disable vector integration

Source

pub fn get_config(&self) -> NNUEConfig

Get current configuration

Source

pub fn save_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>

Save the trained model to a file with full weight serialization

Source

pub fn load_model(&mut self, path: &str) -> Result<(), Box<dyn Error>>

Load a trained model from a file with full weight restoration

Source

pub fn recreate_with_loaded_weights( &mut self, weights: HashMap<String, Tensor>, ) -> CandleResult<()>

Recreate the NNUE with loaded weights (workaround for candle-nn limitations)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,