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.
The examples are organized into the following categories:
Simple examples to help you get started with Neural DSL:
- MNIST Classifier: A simple convolutional neural network for classifying MNIST digits
- Fashion MNIST Classifier: A classifier for the Fashion MNIST dataset
- CIFAR-10 Classifier: A convolutional neural network for classifying CIFAR-10 images
- Iris Classifier: A simple neural network for classifying Iris flowers
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
Examples focused on NLP tasks:
- Text Classification: Text classification model using LSTM
- Named Entity Recognition: Named entity recognition model
- Sentiment Analysis: Sentiment analysis model
- Language Model: Simple language model
- Transformer: Implementation of the Transformer architecture
Examples of generative models:
- Variational Autoencoder: Implementation of a variational autoencoder
- GAN: Implementation of a generative adversarial network
- StyleGAN: Implementation of StyleGAN
- Diffusion Model: Implementation of a diffusion model
Examples of reinforcement learning models:
- DQN: Implementation of Deep Q-Network
- A2C: Implementation of Advantage Actor-Critic
- PPO: Implementation of Proximal Policy Optimization
Examples of models that combine multiple modalities:
- Image Captioning: Model for generating captions for images
- Visual Question Answering: Model for answering questions about images
- Audio-Visual Fusion: Model that combines audio and visual inputs
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.neuralYou can use these examples as starting points for your own models:
- Copy the example file to your working directory
- Modify the model architecture, hyperparameters, or training configuration
- 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.pyEach 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
...
}
We welcome contributions of new examples! To contribute:
- Create a new Neural DSL file in the appropriate category directory
- Include detailed comments explaining the model architecture and implementation
- Add the example to this README
- 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
