Warning: Undefined array key 1 in /home2/readiozm/public_html/matlabsolutions.com/resources/question.php on line 62
What is the cause of my patternnet apapt error?
McDermott asked . 2021-08-03

What is the cause of my patternnet apapt error?

I am trying to do adaptive training of a neural network using patternnet using all default settings, so the following is my complete code (except for array initialisation). The train code works, and is verified to produce accurate output :
 
X is [101,12507] of training data, T is [133,12507] of classification data
 
net = patternnet(101);
net = train(net,X,T);
If I try adaptive training with one sample :
 
X is [101,1] of training data, T is [133,1] of classification data
net = patternnet(101);
net = adapt(net,X,T);

I get the following error:

Error using  * 
Inner matrix dimensions must agree.
Error in nn7.grad2 (line 108)
      gNi(:,qq) = Fdot{qq}' * gA{i}(:,qq);
Error in adaptwb>adapt_network (line 100)
      [gB,gIW,gLW] =
      nn7.grad2(net,[],PD(:,:,ts),BZ,IWZ,LWZ,N,Ac(:,ts+AcInd),gE,Q,1,hints);
      Error in adaptwb (line 37)
    [out1,out2,out3] = adapt_network(in1,in2,in3,in4);
Error in network/adapt (line 108)
[net,Ac,tr] = feval(net.adaptFcn,net,Pd,T,Ai);
Error in D_Train_Net_Adapt (line 14)
    net = adapt(net,X,T);

 

patternnet adapt

Expert Answer

Prashant Kumar answered . 2024-05-17 20:08:57

% You are trying to design a classifier that classifies 101-dimensional vectors into one of 133 classes. using a net with 101 hidden nodes.
 
% What kind of input data is that and what kind of target classes are those?
 
% This is such a highly unusual and unlikely scenario that I suggest you illustrate your problem with a MATLAB example dataset.
 
% The documentation commands "help patternnet" and "doc patternnet" both yield examples using the iris_dataset containing fifty 4 dimensional vectors from each of 3 classes
 
% The help and doc commands for adapt indicate it was meant for timeseries, not classification. Nevertheless, it will be interesting to see how well it does.
 
% Removing ending semicolons will print the results of any command
 
 close all, clear all, clc
 [ x, t] = iris_dataset;
 [ I N ] = size(x)   % [ 4 150 ]
 [ O N ] = size(t)   % [ 3 150 ]
% TCI TrueClassIndices: 1, 2 and 3
 TCI = vec2ind(t);  
 H   = 10         % default No. of hidden nodes
% NET TRAINING
 net1 = patternnet(H);
 rng(4151941)       % my RNG initialization
 [ net1 tr y1 e1 ] = train(net1,x,t);
% PCI PredictedClassIndices: 1, 2 and 3
 PCI1    = vec2ind(y1);
 Errors1 = [ PCI1 ~= TCI ]; % 0s and 1s
 Nerrs1  = sum(Errors1)     %  4
 PctErr1 = 100*Nerrs1/N     % 2.67
% NET ADAPTATION
 net2 = patternnet(H);
 rng(4151941)       % my RNG initialization
 [ net2 y2 e2 xf af ar] = adapt(net2,x,t);
% PCI PredictedClassIndices: 1, 2 and 3
 PCI2     = vec2ind(y2);
 Errors2  = [ PCI2 ~= TCI ]; % 0s and 1s
 Nerrs2   = sum(Errors2)     %  91
 PctErr2 = 100*Nerrs2/N      % 60.7
% Since the initial weights and random data divisions depend on the RNG state, many more nets have to be designed before a definitive conclusion can be made about the ability of adapt to be used for this problem.
 


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.