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
impl NeuralPathValidator
Sourcepub fn expected_path_signature(&self, challenge_hash: &str) -> Vec<u8> ⓘ
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
Sourcepub fn compute_actual_path(
&self,
tensor: &Tensor,
nonce: u64,
) -> Result<Vec<u8>, TribeError>
pub fn compute_actual_path( &self, tensor: &Tensor, nonce: u64, ) -> Result<Vec<u8>, TribeError>
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.
Sourcepub fn hamming_distance(a: &[u8], b: &[u8]) -> u32
pub fn hamming_distance(a: &[u8], b: &[u8]) -> u32
Compute Hamming distance between two bit vectors.
Sourcepub fn validate(
&self,
actual_path: &[u8],
challenge_hash: &str,
max_distance: u32,
) -> bool
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.
Sourcepub fn path_to_hex(path: &[u8]) -> String
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
impl Default for NeuralPathValidator
Source§fn default() -> NeuralPathValidator
fn default() -> NeuralPathValidator
Auto Trait Implementations§
impl Freeze for NeuralPathValidator
impl RefUnwindSafe for NeuralPathValidator
impl Send for NeuralPathValidator
impl Sync for NeuralPathValidator
impl Unpin for NeuralPathValidator
impl UnsafeUnpin for NeuralPathValidator
impl UnwindSafe for NeuralPathValidator
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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