2-Layer Neural Network Training and Forecasting Functions

Version 1.0.0.0 (13.3 KB) by Chim Lau
2-Layer Neural Network Training and Forecasting Functions
271 Downloads
Updated 9 May 2018

View License

This is a set of functions I wrote to use supervised learning to infer the outcome (0,1) based on a set of input X, using a 2-layer neural network. The user can customize the values of lambda as well as the size of the layers.
nnMain.m contains an example of using nnCalibrate() and nnPredict() to learn and predict values. The training data is generated from a known mathematical equation (so what Y is known for a given set of Xs). After calibration, nnPredict() is used to predict the value and compared it with what the actual value should be. nnMain also estimates the values using a logit and then compares the forecasting ability of the two methods.

nnCalibrate(modeVal) takes a set of parameter values from calibrateParam.mat and trains on a training set nnTrainData.mat. It saves the learned weights in last_nn_params.mat so that calibration can be rerun with additional training data in the future.
calibrateParam.mat contains a set of parameters values the user defines, including lambda and size of the layers.
last_nn_params.mat contains learning weights generated by nnCalibrate.

nnTrainData.mat contains the m by n matrix nnTrainData supplied by the user. The n-th column should be the target in the domain 0 or 1.

modeVal can be 0, 1, or >1. 0 resets the learning weights. 1 run the calibration for 1 iteration. X >1 runs the calibration for x iterations.

nnPredict(fX) takes a k by n-1 matrix fX and makes prediction using the learning weights in last_nn_params.mat.

Cite As

Chim Lau (2024). 2-Layer Neural Network Training and Forecasting Functions (https://www.mathworks.com/matlabcentral/fileexchange/67269-2-layer-neural-network-training-and-forecasting-functions), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0

Updated the description.