Skip to content

adative learning and early stoping along with refactor and small touches - #1

Open
tndmadman wants to merge 7 commits into
silver0a1:mainfrom
tndmadman:main
Open

adative learning and early stoping along with refactor and small touches#1
tndmadman wants to merge 7 commits into
silver0a1:mainfrom
tndmadman:main

Conversation

@tndmadman

@tndmadman tndmadman commented Jun 27, 2025

Copy link
Copy Markdown
  1. Refactored Neuron and Compartment Logic

    Preserved original neuron and dendritic compartment structure.

    Cleaned up variable naming for clarity and consistency.

    Added optional sigmoid and tanh explanations as inline comments.

  2. Enhanced Training Routine

    Added adaptive learning rate decay.

    Introduced early stopping using patience and minDelta.

    Error is now tracked and logged every 1000 epochs for long runs.

  3. Extended Task Support

    Expanded from just XOR and circle classification to:

     Logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR, BUFFER)
    
     Half Adder (SUM, CARRY)
    
     Full Adder (3-input SUM and CARRY)
    

    Implemented label-based multi-output support (universal neuron model).

  4. Multi-Label Training Architecture

    Introduced []float64 expected outputs per training sample.

    Built a universal label-to-index map (labelIndexMap) and corresponding output vector for each logic label.

    All logic gates and combinational circuits are trained simultaneously.

  5. Multithreaded Training

    Training now runs across multiple cores using Go’s sync.WaitGroup and runtime.GOMAXPROCS().

    Training batches are divided and updated in parallel using per-thread gradient accumulation and a mutex-protected global weight update step.

  6. Improved Accuracy Evaluation

    Added clean, structured printout showing input, expected, predicted, rounded output, and correctness.

    Final output includes overall accuracy across all tasks.

  7. New Data Generation Functions

    makeMultiLabelData() produces samples for logic gates and adders.

    generateCircleData() enables spatial classification for non-linear tests.

  8. Other Enhancements

    Added reusable functions like normalizeInput() for data prep.

    Replaced hard-coded gates with scalable, indexed label definitions.

    Added detailed inline comments and structure for clarity and learning.

📁 File Structure & Usage

All logic is contained in a single file (main.go) for now.
Future refactor might include:

neuron.go

training.go

data.go

main.go as entry point

💡 Future Work

Optional: Convert to support GPU via CUDA with cgo/C bindings (complex).

Visualization of decision boundaries (circle classification) or logic outputs.

Export/import weights for persistence.

Build unit tests for each logic block.

Refactor code: removed non-ASCII spaces, ensured all braces match, and normalized formatting with go fmt

Unified logging: consolidated fmt.Printf calls onto single lines using \n

Adaptive learning rate: added initLR parameter, decayed LR by 10% every 2,000 epochs

Early stopping: added patience and minDelta parameters to halt training when no improvement

Enhanced Train signature in both dendritic_neuron.go and dendritic_neuron_circle.go

XOR example (dendritic_neuron.go): updated to use adaptive LR & early stopping, formatted predictions output

Circle example (dendritic_neuron_circle.go): same enhancements plus generateCircleData() and final accuracy report
feat: implement universal dendritic neuron for all logic gates and blocks

- Added universal dendritic neuron model supporting multiple dendritic compartments
- Supports training on classic logic gates (AND, OR, NOT, NAND, NOR, XOR, XNOR, BUFFER)
- Added training data and support for combinational logic blocks: Half Adder and Full Adder (sum and carry)
- Multithreaded training using Go goroutines for better performance
- Adaptive learning rate with decay every 2000 epochs
- Output includes detailed testing results and overall accuracy percentage
- Code refactored for concurrency safety using mutex locks
- Implemented dendritic compartment and neuron models with forward pass and training
- Added adaptive learning rate and early stopping in training loop
- Included XOR logic gate training example
- Added synthetic circle data generation and training for nonlinear classification
- Developed multi-output dendritic neuron for multiple logic gates and combinational logic blocks (AND, OR, NOT, NAND, NOR, XOR, XNOR, BUFFER, Half Adder, Full Adder)
- Implemented multi-threaded training with synchronization for efficiency
- Provided extensive testing and accuracy evaluation for all trained logic gates and blocks
- Improved code modularity with separate structs and training workers
@silver0a1

Copy link
Copy Markdown
Owner

Check out the latest implementations. The most recent successes of tying the neurons together are dann_tumor_bio.go, dann_tumor.go and the sine approximation test with a standard neural network as a control case.

Unaddressed-
Multi-threading(not there yet sorry)
Early-stop
Adaptive learning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants