Borrar filtros
Borrar filtros

Deep Learning Train Bayesian Neural Network

19 visualizaciones (últimos 30 días)
Joy Wang
Joy Wang el 12 de Mzo. de 2024
Respondida: Yash el 18 de Mzo. de 2024
when I use the MATLAB TrainBayesianNeuralNetworkUsingBayesByBackpropExample
I can work with good results as it was offered
However, when I copied this code to m.file , named demo_BNN
I have found lots of problems
in Train model section
mbq = minibatchqueue(dsTrain, ...
MiniBatchSize= miniBatchSize, ...
MiniBatchFcn= @preprocessMiniBatch, ...
MiniBatchFormat=["SSCB" "CB"]);
Error using minibatchqueue>iValidateMiniBatchFcn
Invalid value for 'MiniBatchFcn'. Unable to find function 'preprocessMiniBatch'.
Error in minibatchqueue>iParseInputs (line 786)
iValidateMiniBatchFcn(options.MiniBatchFcn, numVariables, options.NumOutputs);
Error in minibatchqueue (line 288)
options = iParseInputs(numVariables, varargin{:});
Error in demo_BNN (line 82)
mbq = minibatchqueue(dsTrain, ...
However, there are similar operations from document of minibatchqueue
SImilaraly, In monitor section
[elboLoss,rmsError,gradientsNet,gradientsNoise] = dlfeval(@modelLoss, ...
net,X,T,samplingNoise,miniBatchIdx,numIterationsPerEpoch);
Undefined function 'modelLoss' for input arguments of type 'dlnetwork'.
Error in deep.internal.dlfeval (line 17)
[varargout{1:nargout}] = fun(x{:});
Error in deep.internal.dlfevalWithNestingCheck (line 19)
[varargout{1:nargout}] = deep.internal.dlfeval(fun,varargin{:});
Error in dlfeval (line 31)
[varargout{1:nargout}] = deep.internal.dlfevalWithNestingCheck(fun,varargin{:});
Error in demo_BNN (line 123)
[elboLoss,rmsError,gradientsNet,gradientsNoise] = dlfeval(@modelLoss, ...

Respuestas (1)

Yash
Yash el 18 de Mzo. de 2024
Hi Joy,
I tried reproducing the errors on my end. However, "demo_BNN.mlx" is working fine for me. I created a copy of "TrainBayesianNeuralNetworkUsingBayesByBackpropExample.mlx" and renamed it to "demo_BNN.mlx".
Ensure the following to try to resolve the errors:
  • Check that all the supporting functions ("preprocessMiniBatch", "modelPosteriorSample", "logLikelihood", "modelLoss", "negativeELBO", "averageNegativeELBO" and "KLWeight") are defined at the end of "demo_BNN.mlx". These functions are defined in "TrainBayesianNeuralNetworkUsingBayesByBackpropExample.mlx".
  • Check that all the helper .M files are present in the same directory as "demo_BNN.mlx". These files are "bayesFullyConnectedLayer.m", "initializeGlorot.m" and "logProbabilityNormal.m". These files are present in the same directory as "TrainBayesianNeuralNetworkUsingBayesByBackpropExample.mlx".
Attaching "demo_BNN.mlx" and other helper functions for your reference.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by