Skip to content

ArianGohari/neuralnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Neural Network Implementation in Zig

A simple neural network implementation in Zig

Features

  • Multi-layer perceptron with configurable architecture
  • Sigmoid activation function
  • Backpropagation training algorithm
  • Custom tensor operations
  • Loss function implementation

Project Structure

src/
├── main.zig         # Example usage and XOR problem solver
├── network.zig      # Neural network implementation
├── tensor.zig       # Tensor operations
├── activations.zig  # Activation functions
└── loss.zig         # Loss functions

Building and Running

# Build the project
zig build

# Run the neural network
./zig-out/bin/neuralnet

Example Usage

The main program demonstrates training a neural network to solve the XOR problem:

  • Architecture: 2 inputs → 4 hidden neurons → 1 output
  • Training data: XOR truth table
  • Learning rate: 0.5
  • Epochs: 5000

The network learns to map:

  • [0, 0] → 0
  • [0, 1] → 1
  • [1, 0] → 1
  • [1, 1] → 0

Requirements

  • Zig compiler (latest stable version)

About

Neural Network implemented from scratch using Zig

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages