Making custom neural network layer with state, doesn't accept unformatted dlarray
显示 更早的评论
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
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!