Skip to main content

NeuralPathValidator

Struct NeuralPathValidator 

Source
pub struct NeuralPathValidator {
    pub layer_widths: Vec<usize>,
}
Expand description

Validates the neural inference path of a tensor computation.

Models the tensor operation as a small feedforward network. The “path” is the binary activation pattern at each layer (ReLU > 0 = 1, else 0). The miner must find a nonce that makes the actual path match an expected path signature (derived from the challenge) within a Hamming distance.

Fields§

§layer_widths: Vec<usize>

Layer widths for the feedforward network

Implementations§

Source§

impl NeuralPathValidator

Source

pub fn expected_path_signature(&self, challenge_hash: &str) -> Vec<u8>

Derive the expected path signature from the challenge hash. Returns a bit vector (as Vec of 0/1 values) representing the expected activations.

Source

pub fn compute_actual_path( &self, tensor: &Tensor, nonce: u64, ) -> TribeResult<Vec<u8>>

Compute the actual activation path for a tensor with a given nonce. Simulates a feedforward pass: input -> (linear + ReLU) per layer. Returns the binary activation pattern.

Source

pub fn hamming_distance(a: &[u8], b: &[u8]) -> u32

Compute Hamming distance between two bit vectors.

Source

pub fn validate( &self, actual_path: &[u8], challenge_hash: &str, max_distance: u32, ) -> bool

Validate that the actual path is close enough to the expected path.

Source

pub fn path_to_hex(path: &[u8]) -> String

Encode path bits as a compact hex string for on-chain storage.

Trait Implementations§

Source§

impl Default for NeuralPathValidator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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, 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> Same for T

Source§

type Output = T

Should always be Self
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.