Verification failed to check the validity of the customize layer with Incorrect type of 'Z' for 'predict'

16 visualizaciones (últimos 30 días)
I want to create a customized deep learning layer with nested dlnetwork according to the example presented in Example. After creating the customized layer, I use checkLayer function to check the validity of the layer. The messages displayed in the command window are illustrated as follows:
Running nnet.checklayer.TestLayerWithoutBackward
.......... .......
================================================================================
Verification failed in nnet.checklayer.TestLayerWithoutBackward/predictIsConsistentInType(Precision=double,Device=gpu).
----------------
Test Diagnostic:
----------------
Incorrect type of 'Z' for 'predict'.
---------------------
Framework Diagnostic:
---------------------
Actual Underlying Type:
single
Expected Underlying Type:
double
------------------
Stack Information:
------------------
In
In
================================================================================
The failure message says that the underlying data type are not consistent. I want to know how to retain the consistency when test the customized layer in GPU device and CPU device.

Respuesta aceptada

Chuguang Pan
Chuguang Pan hace alrededor de 11 horas
After debugging for a long time, I find that the issue is caused by the default initialization of single precision in dlnetwork's learnable parameters and state parameters. In the predict function and forward function, use cast function to convert the precision before making forward propagation !
% ...
castFcn = @(x) cast(x,'like',inputData);
layer.NestedNet.Learnables = dlupdate(castFcn,layer.NestedNet.Learnables);
layer.NestedNet.State = dlupdate(castFcn,layer.NestedNet.State);
[Y,state] = predict(layer.NestedNet,inputData);
% ...
Through casting the precision of dlnetwork's parameters according to the inputData's precision, the issue has been solved.
Running nnet.checklayer.TestLayerWithoutBackward
.......... .......... ........
Done nnet.checklayer.TestLayerWithoutBackward
__________
Test Summary:
28 Passed, 0 Failed, 0 Incomplete, 6 Skipped.
Time elapsed: 0.62726 seconds.
By the way, it is hard to debug the deep learning network and there are many useful MATLAB debugging tools which can be used to facilitate the debugging procudure, such as Conditional Breakingpoints.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by