Skip to content
This repository was archived by the owner on Feb 26, 2026. It is now read-only.

Latest commit

 

History

History
156 lines (108 loc) · 5.28 KB

File metadata and controls

156 lines (108 loc) · 5.28 KB

Neural Examples

Examples Overview

Overview

This directory contains example Neural DSL files demonstrating various use cases and model architectures. These examples serve as both documentation and starting points for your own models. Each example includes detailed comments explaining the model architecture and implementation details.

Example Categories

The examples are organized into the following categories:

1. Basic Examples

Simple examples to help you get started with Neural DSL:

2. Computer Vision Examples

Examples focused on computer vision tasks:

  • ResNet: Implementation of the ResNet architecture
  • VGG: Implementation of the VGG architecture
  • MobileNet: Implementation of the MobileNet architecture
  • Object Detection: Object detection model using SSD
  • Segmentation: Image segmentation model using U-Net

3. Natural Language Processing Examples

Examples focused on NLP tasks:

4. Generative Models

Examples of generative models:

5. Reinforcement Learning

Examples of reinforcement learning models:

  • DQN: Implementation of Deep Q-Network
  • A2C: Implementation of Advantage Actor-Critic
  • PPO: Implementation of Proximal Policy Optimization

6. Multi-Modal Models

Examples of models that combine multiple modalities:

Using the Examples

Running an Example

To run an example, use the Neural CLI:

# Compile the example to TensorFlow
neural compile examples/basic/mnist_classifier.neural --backend tensorflow

# Run the compiled model
neural run mnist_classifier_tensorflow.py

# Visualize the model architecture
neural visualize examples/basic/mnist_classifier.neural

Modifying an Example

You can use these examples as starting points for your own models:

  1. Copy the example file to your working directory
  2. Modify the model architecture, hyperparameters, or training configuration
  3. Compile and run the modified model
# Copy an example
cp examples/basic/mnist_classifier.neural my_model.neural

# Edit the model
nano my_model.neural

# Compile and run the modified model
neural compile my_model.neural --backend tensorflow
neural run my_model_tensorflow.py

Example Structure

Each example follows a consistent structure:

network ModelName {
  // Input specification
  input: (input_shape)

  // Layer definitions
  layers:
    Layer1(params)
    Layer2(params)
    ...
    Output(params)

  // Training configuration
  loss: loss_function
  optimizer: optimizer_type(params)
  metrics: [metric1, metric2, ...]

  // Hyperparameters
  batch_size: value
  epochs: value
  ...
}

Contributing Examples

We welcome contributions of new examples! To contribute:

  1. Create a new Neural DSL file in the appropriate category directory
  2. Include detailed comments explaining the model architecture and implementation
  3. Add the example to this README
  4. Submit a pull request

Please follow these guidelines when contributing examples:

  • Use clear, descriptive names for models and variables
  • Include detailed comments explaining the model architecture
  • Follow the existing example structure
  • Test the example to ensure it works with the Neural CLI

Resources