Making custom neural network layer with state, doesn't accept unformatted dlarray
Show older comments
Made a custom nnet layer, with a state property. Tried following the documentation on how to pass state etc through the functions.
Unfortunately, when testing the layer with
checkLayer(mweLayer,1);
I get the error
``` Error using 'predict' in Layer mweLayer. 'property' must be a real-valued finite numeric array or an unformatted dlarray object.```
As you can see in this example, even with a small unformatted dlarray, the error is thrown. Am I not allowed dlarrays in state properties at all? Is there somewhere else the error is coming from?
classdef mweLayer < nnet.layer.Layer
properties (State)
property
end
methods
function layer = mweLayer(name)
arguments
name = "mweLayer"
end
layer.Name = name;
layer.property = dlarray([1 2 3]);
end
function [Z,state] = predict(layer,X)
Z = X;
state.property = dlarray([1 2 3]);
end
function layer = resetState(layer)
layer.property = dlarray([1 2 3]);
end
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!