I'm facing an error with a custom intermediate layer using the Deep Learning Toolbox. The layer gets sequence input data, has two states and no learnable parameters. Its task is simply to output the difference between the current input and the input at the previous time step. I tried designing the layer according to the peephole LSTM example (https://de.mathworks.com/help/deeplearning/ug/define-custom-recurrent-deep-learning-layer.html). Unfortunately, when I try to construct the layer using
I get the error message:
Error using forwardDifferenceLayer
Illegal attribute 'State'.
Here's my code for the layer. Can anyone see what I'm doing wrong? Thanks a lot in advance.
classdef forwardDifferenceLayer < nnet.layer.Layer & nnet.layer.Formattable
function layer = forwardDifferenceLayer(numHiddenUnits, args)
layer.NumHiddenUnits = numHiddenUnits;
function [Z,hiddenState,cellState] = predict(layer,X)
hiddenState = zeros(size(X));
hiddenState = X - layer.CellState;
Z = dlarray(single(hiddenState));
function layer = resetState(layer)
layer.HiddenState = zeros(layer.NumHiddenUnits,1);
layer.CellState = zeros(layer.NumHiddenUnits,1);