MATLAB Answers

Conversion to double from gpuArray is not possible.

42 views (last 30 days)
Raza Ali
Raza Ali on 1 Sep 2020
Commented: Raza Ali on 3 Sep 2020
I am training a CNN with some modification in classification layer. I have called a function in loss layer but when i start training the netwrok i get the folowing error:
Error using 'forwardLoss' in Layer ClassificationLayer. The function threw an error and could not be executed.
Caused by:
The following error occurred converting from gpuArray to double:
Conversion to double from gpuArray is not possible.
How to resolve this issue.?

Answers (1)

Raymond Norris
Raymond Norris on 1 Sep 2020
Raza,
My guess is that forwardLoss takes one or more input arguments, one of which is being passed a gpuArray instead of a double. Before calling forwardLoss, you can gather the data from the GPU to the CPU as such:
% GPU array "ga"
ga = ...
% Copy the data from the GPU to the CPU into "a"
a = gather(ga);
% Call forwardLoss fcn
forwardLoss(a,...);
  3 Comments
Raza Ali
Raza Ali on 3 Sep 2020
Thank you Edric Ellis, although the code is still not executable but 'like' and 'dbstop' helped alot to understand the process.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!