Introduction to Neural Networks for Java, Session 2

Course NameIntroduction to Neural Networks for Java
Instructorjeffheaton
Session TitleMatrix Operations
Session Number2

Session Material

Matrixes

Matrixes are the mathematical foundation upon which neural networks are based. Other mathematical disciplines come into play throughout this course, but none as pervasive as matrixes. Because of this, we devote one entire class session to matrixes. Further, the book develops three classes that are used for matrixes. These classes are listed here.

  • Matrix - Holds a matrix.
  • MatrixMath - Used to perform mathematical operations on a matrixes.
  • BiPolarUtil - Used to convert between bipolar numbers and boolean.

Matrix Mathematics

Using the MatrixMath class you can perform many matrix operations. The MatrixMath class does not attempt to contain every possible mathematical operation that can be performed on a matrix. Rather, it is an attempt to encapsulate every matrix operation that will be needed in this course. Some of the operations supported include:

  • Addition
  • Division by a Scalar
  • Dot Product
  • Identity Matrix
  • Multiplication by a Matrix
  • Multiplication by a Scalar
  • Subtraction
  • Transpose
  • Length

If you are having trouble visualizing how any of the above matrix mathematical operations are carried out you should look at the "Matrix Solving" page at Heaton Research. This page contains calculators for some of the more common matrix operations. Further, the matrix solvers will show the intermediate steps needed to calculate. The matrix solver can be found at the following location.

[Matrix Math]

BiPolar

Neural networks store numbers as floating point decimals. Yet neural networks are often called upon to process data that is not in a floating point form. One of the real skills you will develop as a neural network programmer is how to take real world data and present it in a form that the neural network can deal with.

One such form data is boolean. Often you will want to present boolean data to the neural network. Neural networks cannot deal with boolean data. Because of this the boolean data must be converted into floating point. The following two numbers can "stand in" for true and false.

  • true becomes 1.
  • false becomes -1.

You may be wondering, why not just represent the boolean data using 1.0 and 0.0. These two numbers are not equidistant from zero. Nor are they opposite. -1 and 1 are opposite, just as true and false are opposite.

It is also possible to convert between binary and boolean using algebraic equations. The following equation converts from boolean to bipolar.

Likewise, the following equation converts from bipolar to boolean.

The Weight Matrix

The primary use for matrixes is to hold the weight matrix. The weight matrix contains the memory between two layers of the neural network. Threshold values are often combined with the weight matrix. This allows a single matrix to represent the entire memory between two layers.

Homework Assignment

This assignment will ensure that you know how to access the examples downloads from the book. They can be found at http://www.heatonresearch.com/download/. Use the Matrix and MatrixMath classes. Create a simple example that demonstrates that multiplying by the identity matrix results in the same matrix. Construct a 2x2 matrix that contains the following numbers:

1   2
3   4

Use MatrixMath to create an identity matrix for a 2x2 matrix. Multiply the above matrix by the identity and compare the resulting matrix to the original matrix. There should be no differences.

If you have trouble with this, ask questions in the forum, and someone will respond. I will not collect the homework assignments, they are to check your understanding. If you have trouble, please ask questions!

Videos for this Session

Videosort iconTitle
Introduction to Neural Networks for Java(Class 2/16, Part 1/5)Introduction to Neural Networks for Java(Class 2/16, Part 1/5)
Introduction to Neural Networks for Java(Class 2/16, Part 2/5)Introduction to Neural Networks for Java(Class 2/16, Part 2/5)
Introduction to Neural Networks for Java(Class 2/16, Part 3/5)Introduction to Neural Networks for Java(Class 2/16, Part 3/5)
Introduction to Neural Networks for Java(Class 2/16, Part 4/5)Introduction to Neural Networks for Java(Class 2/16, Part 4/5)
Introduction to Neural Networks for Java(Class 2/16, Part 5/5)Introduction to Neural Networks for Java(Class 2/16, Part 5/5)

Copyright 2005 - 2010 by Heaton Research, Inc.. Heaton Research™ and Encog™ are trademarks of Heaton Research. Click here for copyright and trademark information.