"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?

采纳的回答

Venu
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
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 CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by