"The value of 'Layer' is invalid. Layers that require formatted dlarray inputs are not supported." - Why is this error shown when checked the validity of a custom layer?
2 次查看(过去 30 天)
显示 更早的评论
I be created a customized layer based on attention mechanism for deep learning application using https://in.mathworks.com/help/deeplearning/ug/define-custom-deep-learning-layer.html. But while checking the validity of layer using the following code:
layer=CoAtten(Name="atten");
validInputSize = [1 14 1024];
layout = networkDataLayout(validInputSize,"CBT");
layer = initialize(layer,layout);
checkLayer(layer,validInputSize,ObservationDimension=3)
The last line (checkLayer) shows the error like this- ""The value of 'Layer' is invalid. Layers that require formatted dlarray inputs are not supported."
What this error shows? Is the custom layer is invalid? I have used stripdims inside the predict fuction while creating the layer. Is it due to this?
0 个评论
采纳的回答
Venu
2023-12-11
The error while using checkLayer "The value of 'Layer' is invalid. Layers that require formatted dlarray inputs are not supported" occurs when the custom layer's predict function does not handle the dlarray inputs correctly. Your inference is correct. In your case, when using "stripdims", it's important to ensure that the input dlarray aligns with the expected input format. This includes verifying the dimensions and data type of input dlarray.
Find the documentation below for dlarray, checkLayer and stripdims to ensure that your custom layer's predict function aligns with the expected input format.
Hope this helps!
7 个评论
Venu
2023-12-14
Make sure that the "CoAtten.m" file is included with the saved network and is on the MATLAB path or in the current working directory when loading the network on any system. Check the initialize() function of your "CoAtten" class to ensure that it does not rely on external variables or states that might not be available when loading the network. The method should be self-contained.
You can try adding error handling in the initialize() function to catch any issues.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!