From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Simple LabVIEW Neural Network using LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview
This code implements a simple artifical neural network to simulate an XOR logic gate. The neural network consists of two input nodes (X and Y), three hidden nodes, and an output node.

 

Description
This program will use the backpropagation algorithm to train itself to produce an XOR output. My goal in making this was to implement backpropagation in LabVIEW. It's not the prettiest code, but I'm hoping it will be useful to people trying to understand how neural networks work. Essentially I implemented the math found in this video, and then applied it using an XOR function for training. The code uses functional global variables (FGVs) heavily to avoid wires going everywhere, so brush up on FGVs if you have not used them before.

For more information on Artificial Neural Networks, I highly recommend watching this series of videos.

 

Steps to Implement or Execute Code

  1. Run Neural Network_XOR.vi (this VI will train the neural network)
  2. Run FeedForward.vi (this VI allows you to test the neural network)

 
Requirements

Software:

  1. LabVIEW 2015 (or compatible)

Steps to Implement or Execute Code

  1. Download the .zip file
  2. Set your desired configuration (a, x1, x2, degrees, etc)
  3. Run the VI

 

Additional Information or References
VI Block Diagram

1.png

 **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.