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,
) -> TribeResult<Vec<u8>>
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.
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.