MATLAB Answers


Conversion to struct from double is not possible- Neural Network Pattern Recognition Toolbox

Asked by Chaou
on 28 Jul 2013
Latest activity Edited by John D'Errico
on 15 Jun 2014

Hello. I'm trying to execute the simplest example for Pattern recognition network, given in this link for iris flowers classification.

 [x,t] = iris_dataset;
net = patternnet(10)
net = train(net,x,t);
y = net(x);
perf = perform(net,t,y)
classes = vec2ind(y)

Error using struct Conversion to struct from double is not possible.

And it's the same error if I use the Neural Network interface. Can anyone help me, please? Thank you very much!


Jan Simon
on 28 Jul 2013

Please be so kind and post the complete error message. Most of all show us the line, which causes the error and explain the type of the used variables.

ML guy
on 14 Jun 2014

When I cut and paste his code (on a mac running R2014a and MacOS 10.9.3), I get this error:

Error using struct
Conversion to struct from double is not possible.
Error in network/subsasgn>getDefaultParam (line 2048)
    param = struct(feval(fcn,'defaultParam'));
Error in network/subsasgn>setLayerTransferFcn (line 1224)
net.layers{i}.transferParam = getDefaultParam(transferFcn);
Error in network/subsasgn>network_subsasgn (line 208)
        if isempty(err), [net,err] =
        setLayerTransferFcn(net,i,transferFcn); end
Error in network/subsasgn (line 13)
net = network_subsasgn(net,subscripts,v,netname);
Error in patternnet>create_network (line 104)
  net.layers{net.numLayers}.transferFcn = 'softmax';
Error in patternnet (line 71)
    net = create_network(param); 
ML guy
on 14 Jun 2014

I discovered that the cause of my replication of your error was the fact that I had redefined the 'softmax' function in my MATLAB workspace. There are a number of functions that would cause this error if you redefine them, such as: netsum purelin tansig dividerand mse adaptwb learngdm crossentropy softmax


No products are associated with this question.

1 Answer

Answer by Greg Heath
on 28 Jul 2013
 Accepted answer

I cut and pasted your code. It ran with no problem or messages.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!