Error in matlab included deep learning example

5 visualizaciones (últimos 30 días)
Javier Bush
Javier Bush el 15 de Oct. de 2019
Editada: Walter Roberson el 30 de Dic. de 2019
I am trying to run the matlab example
openExample('nnet/SeqToSeqClassificationUsing1DConvAndModelFunctionExample')
In 2019b but, when i change to train the network on gpu the example show me this error. Please help me to run it or give me a workaround to train using gpu.
Error using gpuArray/subsasgn
Attempt to grow array along ambiguous dimension.
Error in deep.internal.recording.operations.ParenAssignOp/forward (line 45)
x(op.Index{:}) = rhs;
Error in deep.internal.recording.RecordingArray/parenAssign (line 29)
x = recordBinary(x,rhs,op);
Error in dlarray/parenAssign (line 39)
objdata(varargin{:}) = rhsdata;
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>maskedCrossEntropyLoss (line 484)
loss(i) = crossentropy(dlY(:,i,idx),dlT(:,i,idx),'DataFormat','CBT');
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>modelGradients (line 469)
loss = maskedCrossEntropyLoss(dlY, dlT, numTimeSteps);
Error in deep.internal.dlfeval (line 18)
[varargout{1:nout}] = fun(x{:});
Error in dlfeval (line 40)
[varargout{1:nout}] = deep.internal.dlfeval(fun,varargin{:});
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample (line 284)
[gradients, loss] = dlfeval(@modelGradients,dlX,Y,parameters,hyperparameters,numTimeSteps);
Thanks!
  1 comentario
Edric Ellis
Edric Ellis el 15 de Oct. de 2019
Thanks for reporting this - I can reproduce the problem using R2019b here, I shall forward this to the development team...

Iniciar sesión para comentar.

Respuesta aceptada

Joss Knight
Joss Knight el 15 de Oct. de 2019
There is a bug in this Example which will be rectified. Thanks for reporting. To workaround, initialize the loss variable in the maskedCrossEntropyLoss function:
function loss = maskedCrossEntropyLoss(dlY, dlT, numTimeSteps)
numObservations = size(dlY,2);
loss = zeros([1,1],'like',dlY); % Add this line
for i = 1:numObservations
idx = 1:numTimeSteps(i);
loss(i) = crossentropy(dlY(:,i,idx),dlT(:,i,idx),'DataFormat','CBT');
end
end
  6 comentarios
Javier Bush
Javier Bush el 26 de Oct. de 2019
Thanks, I can change miniBatchSize now.
Zekun
Zekun el 29 de Dic. de 2019
Editada: Walter Roberson el 30 de Dic. de 2019
I found another solution for
"Error using gpuArray/subsasgn
Attempt to grow array along ambiguous dimension."
In dlarray/parenAssign.m, at this location:"\R2019b\toolbox\nnet\deep\@dlarray\parenAssign.m"
Line 15:
obj = zeros(0, 0, 'like', rhs);
Replace line 15 with the following 2 lines:
szrhs = size(rhs);
obj = zeros(szrhs(1), szrhs(2), 'like', rhs);
Users cannot directly edit this file, so I backed it up and replace it with a new file.

Iniciar sesión para comentar.

Más respuestas (2)

Javier Bush
Javier Bush el 16 de Oct. de 2019
Thanks it worked!

Linda Koletsou Soulti
Linda Koletsou Soulti el 22 de Oct. de 2019
Thank you for reporting the issue. The error you are getting is related to an attempt to grow a gpuArray using linear indexing assignment.
For more information please refer to the following bug report:
  1 comentario
Javier Bush
Javier Bush el 23 de Oct. de 2019
Linda,
I just changed the miniBatchSize to 2, in the same example and I get the following error, could you please help me with that? I think this is a bug because that is offered as a parameter in the example but you cannot change it.
Index exceeds the number of array elements (1).
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>maskedCrossEntropyLoss (line 486)
idx = 1:numTimeSteps(i);
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample>modelGradients (line 472)
loss = maskedCrossEntropyLoss(dlY, dlT, numTimeSteps);
Error in deep.internal.dlfeval (line 18)
[varargout{1:nout}] = fun(x{:});
Error in dlfeval (line 40)
[varargout{1:nout}] = deep.internal.dlfeval(fun,varargin{:});
Error in SeqToSeqClassificationUsing1DConvAndModelFunctionExample (line 287)
[gradients, loss] = dlfeval(@modelGradients,dlX,Y,parameters,hyperparameters,numTimeSteps);

Iniciar sesión para comentar.

Categorías

Más información sobre Sequence and Numeric Feature Data Workflows en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by