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

17 vues (au cours des 30 derniers jours)
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.
  1 commentaire
Chuguang Pan
Chuguang Pan il y a 30 minutes
I have also checked the validity of the example's residualBlockLayer, it still produces the same failure message as shown above.

Connectez-vous pour commenter.

Réponse acceptée

Chuguang Pan
Chuguang Pan il y a environ 3 heures
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.

Plus de réponses (0)

Catégories

En savoir plus sur Image Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by