pub struct FullyConnected { /* private fields */ }Expand description
Fully connected (dense) wiring structure.
Every neuron connects to every other neuron (and optionally to itself). This provides a baseline comparison for NCP’s sparse connectivity.
§When to Use
- Baseline comparison: Compare NCP performance against dense networks
- Maximum expressiveness: When sparsity is not a concern
- Debugging: Simpler structure for testing
§Sparsity
FullyConnected has no sparsity - the adjacency matrix is fully populated.
For a network with N units, this means N² internal synapses (or N²-N without self-connections).
§Example
use ncps::wirings::{FullyConnected, Wiring};
// Create a fully-connected wiring with 32 neurons, 8 outputs
let mut wiring = FullyConnected::new(
32, // units (total neurons)
Some(8), // output_dim (motor neurons)
42, // seed for reproducibility
true, // self_connections allowed
);
// Build with input dimension
wiring.build(16);
// Check connectivity
println!("Total synapses: {}", wiring.synapse_count()); // 32*32 = 1024
println!("Sensory synapses: {}", wiring.sensory_synapse_count()); // 16*32 = 512§Comparison with NCP
| Aspect | FullyConnected | NCP |
|---|---|---|
| Synapses | O(N²) | O(N) to O(N log N) |
| Interpretability | Low | High |
| Parameters | More | Fewer |
| Structure | Single layer | 4-layer biological |
Implementations§
Source§impl FullyConnected
impl FullyConnected
pub fn new( units: usize, output_dim: Option<usize>, erev_init_seed: u64, self_connections: bool, ) -> Self
Sourcepub fn get_full_config(&self) -> WiringConfig
pub fn get_full_config(&self) -> WiringConfig
Get configuration for serialization
pub fn from_config(config: WiringConfig) -> Self
Trait Implementations§
Source§impl Clone for FullyConnected
impl Clone for FullyConnected
Source§fn clone(&self) -> FullyConnected
fn clone(&self) -> FullyConnected
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FullyConnected
impl Debug for FullyConnected
Source§impl Wiring for FullyConnected
impl Wiring for FullyConnected
Source§fn units(&self) -> usize
fn units(&self) -> usize
Returns the total number of neurons (hidden units) in this wiring. Read more
Source§fn input_dim(&self) -> Option<usize>
fn input_dim(&self) -> Option<usize>
Returns the input dimension (number of input features), or
None if not yet built. Read moreSource§fn output_dim(&self) -> Option<usize>
fn output_dim(&self) -> Option<usize>
Returns the output dimension (number of motor neurons). Read more
Source§fn build(&mut self, input_dim: usize)
fn build(&mut self, input_dim: usize)
Builds the wiring by setting the input dimension and creating sensory connections. Read more
Source§fn adjacency_matrix(&self) -> &Array2<i32>
fn adjacency_matrix(&self) -> &Array2<i32>
Returns the internal adjacency matrix representing neuron-to-neuron synapses. Read more
Source§fn sensory_adjacency_matrix(&self) -> Option<&Array2<i32>>
fn sensory_adjacency_matrix(&self) -> Option<&Array2<i32>>
Returns the sensory adjacency matrix (input-to-neuron connections). Read more
Source§fn add_synapse(&mut self, src: usize, dest: usize, polarity: i32)
fn add_synapse(&mut self, src: usize, dest: usize, polarity: i32)
Adds or modifies an internal synapse between two neurons. Read more
Source§fn add_sensory_synapse(&mut self, src: usize, dest: usize, polarity: i32)
fn add_sensory_synapse(&mut self, src: usize, dest: usize, polarity: i32)
Adds or modifies a sensory synapse from an input feature to a neuron. Read more
Source§fn get_config(&self) -> WiringConfig
fn get_config(&self) -> WiringConfig
Creates a serializable configuration for this wiring. Read more
Source§fn num_layers(&self) -> usize
fn num_layers(&self) -> usize
Returns the number of logical layers in this wiring. Read more
Source§fn get_neurons_of_layer(&self, layer_id: usize) -> Vec<usize>
fn get_neurons_of_layer(&self, layer_id: usize) -> Vec<usize>
Returns the neuron IDs belonging to a specific layer. Read more
Source§fn is_built(&self) -> bool
fn is_built(&self) -> bool
Returns
true if the wiring has been built (input dimension is set). Read moreSource§fn get_type_of_neuron(&self, neuron_id: usize) -> &'static str
fn get_type_of_neuron(&self, neuron_id: usize) -> &'static str
Returns the type of a neuron by its ID. Read more
Source§fn erev_initializer(&self) -> Array2<i32>
fn erev_initializer(&self) -> Array2<i32>
Returns the reversal potential initializer (same as adjacency matrix). Read more
Source§fn sensory_erev_initializer(&self) -> Option<Array2<i32>>
fn sensory_erev_initializer(&self) -> Option<Array2<i32>>
Returns the sensory reversal potential initializer. Read more
Source§fn synapse_count(&self) -> usize
fn synapse_count(&self) -> usize
Returns the total number of internal synapses (non-zero entries in adjacency matrix). Read more
Source§fn sensory_synapse_count(&self) -> usize
fn sensory_synapse_count(&self) -> usize
Returns the total number of sensory synapses (input-to-neuron connections). Read more
Source§fn input_required(&self) -> bool
fn input_required(&self) -> bool
Returns
true if this wiring requires external input (has sensory connections). Read moreAuto Trait Implementations§
impl Freeze for FullyConnected
impl RefUnwindSafe for FullyConnected
impl Send for FullyConnected
impl Sync for FullyConnected
impl Unpin for FullyConnected
impl UnwindSafe for FullyConnected
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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