File Exchange

image thumbnail


version (8.41 KB) by Yuto Ozaki
LSTM module including forward propagation and backward propagation algorithm


Updated 08 May 2016

View License

This code implements forward propagation and backward propagation of Long-Short Term Memory recurrent neural network. Please note this code is a part of a library so please see below for how to use. This file (LSTM.m) extends BaseLayer class (classdef LSTM < BaseLayer) but it can be deleted.
obj.vis = vis; % number of dimension of input vector
obj.hid = hid; % number of dimension of output vector
obj.T = T; % Length of time step for BPTT
obj.batchSize = batchSize; % size of mini-batch
obj.prms = cell(obj.prmNum, 1); % container for parameters
obj.states = cell(obj.stateNum,1); % container for state of gates, memory cell, hidden units = zeros(vis, batchSize, T); % delta to be passed to a lower layer

obj.gprms = obj.prms;

<forward propagation>
LSTM.affineTrans(input); % input should be a matrix size of vis * batchSize * T
output = LSTM.nonlinearTrans();

<backward propagation>
dgate = LSTM.bpropGate(delta); % this delta is from a upper layer
newDelta = LSTM.bpropDelta(dgate);

Cite As

Yuto Ozaki (2021). LSTM (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2016a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!