YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

Snow Spike Project

Overview

Snow Spike is a Python project implementing entropy calculation, normalization, decay mechanisms, and living weights for a neural network system. The project focuses on implementing four key components:

  1. True Discrete Entropy for Ternary Spikes - Calculate Shannon entropy for neurons with discrete states
  2. Normalization of Update Terms - Ensure consistent scaling of different signals
  3. Decay Discretization - Implement decay mechanisms for scores over time
  4. Living Weights - Biologically-inspired adaptive weights that change based on activity patterns

MLX Integration

This project leverages the MLX framework for efficient computation. MLX is a machine learning framework designed for Apple Silicon, providing accelerated computation for array operations.

Project Structure

snow_spike/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ entropy/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── spike_entropy.py
β”‚   β”œβ”€β”€ normalization/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── signal_normalization.py
β”‚   β”œβ”€β”€ decay/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   └── decay_mechanisms.py
β”‚   β”œβ”€β”€ weights/
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ living_weight.py
β”‚   β”‚   └── adaptive_network.py
β”‚   └── utils/
β”‚       β”œβ”€β”€ __init__.py
β”‚       └── common.py
β”œβ”€β”€ tests/
β”‚   β”œβ”€β”€ entropy/
β”‚   β”‚   └── test_spike_entropy.py
β”‚   β”œβ”€β”€ normalization/
β”‚   β”‚   └── test_signal_normalization.py
β”‚   β”œβ”€β”€ decay/
β”‚   β”‚   └── test_decay_mechanisms.py
β”‚   β”œβ”€β”€ weights/
β”‚   β”‚   └── test_living_weights.py
β”‚   └── utils/
β”‚       └── test_common.py
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ entropy.md
β”‚   β”œβ”€β”€ normalization.md
β”‚   β”œβ”€β”€ decay.md
β”‚   └── living_weights.md
β”œβ”€β”€ examples/
β”‚   β”œβ”€β”€ entropy_example.py
β”‚   β”œβ”€β”€ normalize_example.py
β”‚   β”œβ”€β”€ decay_example.py
β”‚   β”œβ”€β”€ integrated_example.py
β”‚   └── validate_living_weights.py
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ setup.py
β”œβ”€β”€ README.md
└── config.json

Installation

# Clone the repository
git clone https://github.com/username/snow_spike.git
cd snow_spike

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Install the package in development mode
pip install -e .

Usage

Entropy Calculation

from snow_spike.entropy import count_spike_occurrences, calculate_empirical_probabilities
from snow_spike.entropy import compute_neuron_entropy, aggregate_network_entropy
from snow_spike.utils.common import SpikeState

# Count spike occurrences
spike_data = [-1, 0, 1, 0, -1, 0, 0, 1, 0, 0]
counts = count_spike_occurrences(0, spike_data, len(spike_data))

# Calculate probabilities
probabilities = calculate_empirical_probabilities(counts, len(spike_data))

# Compute entropy
neuron_entropy = compute_neuron_entropy(probabilities)

Signal Normalization

from snow_spike.normalization import normalize_logic_check, normalize_cross_check
from snow_spike.normalization import normalize_corroboration_signal
from snow_spike.utils.common import CrossCheckType

# Normalize different signals
logic_norm = normalize_logic_check(1)
cross_norm = normalize_cross_check(0.75, CrossCheckType.COSINE_SIMILARITY)
corr_norm = normalize_corroboration_signal(5, kappa=0.5)

# Calculate trust delta
from snow_spike.normalization import calculate_trust_delta
delta_t = calculate_trust_delta(logic_norm, cross_norm, corr_norm, 0.3, 0.4, 0.3)

Decay Mechanisms

from snow_spike.decay import apply_continuous_decay, DecayManager
from snow_spike.utils.common import DecayStrategy
import time

# Apply continuous decay
initial_value = 1.0
initial_time = time.time() - 3600  # 1 hour ago
current_time = time.time()
decay_lambda = 0.01

decayed_value = apply_continuous_decay(initial_value, initial_time, current_time, decay_lambda)

# Use decay manager
manager = DecayManager(strategy=DecayStrategy.CONTINUOUS_ON_READ)
decayed_value = manager.decay_value(initial_value, initial_time)

Living Weights

from snow_spike.weights import AdaptiveNetwork, LivingWeight

# Create a network with living weights
network = AdaptiveNetwork(
    layer_sizes=[2, 4, 1],
    decay_lambda=0.001,
    growth_rate=0.05
)

# Train on XOR problem
inputs = [[1, 1], [1, -1], [-1, 1], [-1, -1]]
targets = [-1, 1, 1, -1]

# Train the network
history = network.train(inputs, targets, epochs=20)

# Make predictions
output = network.forward([1, -1])

# Calculate network entropy
entropy, layer_entropies = network.calculate_network_entropy()

Running Examples

You can run the provided examples to see each module in action:

# Run specific examples
./run.sh entropy     # Entropy calculation example
./run.sh normalize   # Normalization example 
./run.sh decay       # Decay mechanisms example

# Run the integrated example
python examples/integrated_example.py

# Validate living weights
python examples/validate_living_weights.py

Development

To set up the development environment and run tests:

# Build and test everything
./build_all.sh

# Run tests
pytest tests/

# Check code style
flake8 src tests

Documentation

Detailed documentation for each module is available in the docs/ directory:

References

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Paper for psikosen/snow_spike