Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8997083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:50:26+00:00 2026-06-15T23:50:26+00:00

I´m trying to train a neural network using nprtool and also manually, calling newpr

  • 0

I´m trying to train a neural network using nprtool and also manually, calling newpr and train methods. I use samples oriented as rows, instead of default as columns:

nprtool

Using nprtool there is no problem, but when I call to the automatically generated M-file, the output is:

??? Error using ==> network.train at 145
Targets are incorrectly sized for network.
Matrix must have 24 columns.

Error in ==> create_pr_net at 29
[net,tr] = train(net,inputs,targets);

My inputs are 140×24, and my targets are 140×3.

The generated code by Matlab is:

function net = create_pr_net(inputs,targets)
%CREATE_PR_NET Creates and trains a pattern recognition neural network.
%
%  NET = CREATE_PR_NET(INPUTS,TARGETS) takes these arguments:
%    INPUTS - RxQ matrix of Q R-element input samples
%    TARGETS - SxQ matrix of Q S-element associated target samples, where
%      each column contains a single 1, with all other elements set to 0.
%  and returns these results:
%    NET - The trained neural network
%
%  For example, to solve the Iris dataset problem with this function:
%
%    load iris_dataset
%    net = create_pr_net(irisInputs,irisTargets);
%    irisOutputs = sim(net,irisInputs);
%
%  To reproduce the results you obtained in NPRTOOL:
%
%    net = create_pr_net(inputs,targets);

% Create Network
numHiddenNeurons = 2000;  % Adjust as desired
net = newpr(inputs,targets,numHiddenNeurons);
net.divideParam.trainRatio = 90/100;  % Adjust as desired
net.divideParam.valRatio = 5/100;  % Adjust as desired
net.divideParam.testRatio = 5/100;  % Adjust as desired

% Train and Apply Network
[net,tr] = train(net,inputs,targets);
outputs = sim(net,inputs);

% Plot
plotperf(tr)
plotconfusion(targets,outputs)

I am using Matlab R2010a.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:50:27+00:00Added an answer on June 15, 2026 at 11:50 pm

    As mentioned in Matlab help file:

    INPUTS – RxQ matrix of Q R-element input samples
    TARGETS – SxQ matrix of Q S-element associated target samples

    You probably need a transpose of input and target matrix, before calling the Matlab train function manually.

    Input = Input'; and
    Taget = Target';

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to pre-process biological data to train a neural network and despite
I'm trying to train an ANN (I use this library: http://leenissen.dk/fann/ ) and the
I've just recently started using libsvm. I've been trying for awhile to train my
I'm trying to train a gbm using the caret package in R. I initially
I am trying to train a feedforward network to work to perform an XOR
The problem I've encountered after trying to train neural networks isn't a new one
I'm very new to OpenCV. I am trying to use the CvNormalBayesClassifier to train
I am trying to train a Hidden Markov Model (HMM) using the GHMM library
I am trying to build fann neural network library in ubuntu 12.04 but failed
I'm trying to train a set of ~30,000 instances using an SMO classifier with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.