Neural Networks Warehouse
Artificial Intelligence Depot
"As knowledge increases, ignorance unfolds." -Kennedy
KNOWLEDGE MESSAGES SUBMIT SEARCH  
MAtlab Source Code
Source code for Back Propagation
 
• MAtlab Source Code

Hi,

Anyone has source codes for backpropagation for matlab so that I can link it to visual basic program? I would like to create a interface so that my input values can be keyed into the interface, and produce a result from the existing network.
Do anyone know the function in matlab for randomization of my data so that I can use some of my data for training and the rest for the testing? I only could find functions that generate numbers randomly? What I want is to pick my data randomly so that I can ensure a fair test.

Thank You!

34 posts.
Monday 26 January, 08:25
Reply
• Sampling without replacement in MATLAB

Let 'A' be the data array, with examples in rows and variables in columns. Assume that 1000 samples are desired, for, perhaps, training as opposed to testing. Try this:

% Number of samples to draw
TrainN = 1000;

% Generate scrambled index of 'A'
TrainRows = randperm(size(A,1))';

% Only keep so many of them
TrainRows = TrainRows(1:TrainN);

% Extract rows of interest
TrainData = A(TrainRows,:);

-Predictor
http://will.dwinnell.com

249 posts.
Monday 26 January, 09:28
Reply
• Random picking

Thankz for replying on the randomisation.

I have tried but still failed to pick data randomly from my input and output files. With 2 different files (input and output), how is it possible that I can ensure that the randomly picked data is from the same set with 2 different files?
randperm is a function that generates random numbers at a given range. That is not what I want.Do you the correct function for my application using Matlab?

Thankz for ur help!

34 posts.
Monday 02 February, 11:29
Reply
• Uh... ?

Did you actually read the code I posted? I only used the first 1000 values of 'randperm', which yields 1000 distinct, randomly drawn row (case) numbers. These numbers are stored in the variable 'TrainRows', and can be used to index as many arrays as you like:

% Extract input and output components of training data:
TRAININ = INPUTDATA(TrainRows,:);
TRAINOUT = OUTPUTDATA(TrainRows,:);

-Predictor
http://will.dwinnell.com

249 posts.
Monday 02 February, 14:53
Reply
• randomisation

Thank you very much. I have succeeded in picking out the necessary data both from the input and output file. However, how do I pick the remaining data that is not chosen at first so that I can use the other rest for testing?

34 posts.
Wednesday 04 February, 02:36
Reply
• SRS w/o Replacement of Train, Test Sets in MATLAB

Again, let 'A' be the data array, with examples in rows and variables in columns. Assume that 1000 samples are desired, for, perhaps, training as opposed to testing. Try this:

% Number of samples to draw
TrainN = 1000;

% Generate scrambled index of 'A'
RandIndex = randperm(size(A,1))';

% Get Training rows only
TrainRows = RandIndex(1:TrainN);

% Get Test rows only
TestRows = RandIndex(TrainN+1:end);

Obviously, this can easily be extended to Train, Test and Validation sets, etc., but if one requires selection for things like k-fold cross-validation, it is probably easier to use something like:

% Generate 10-way partition of 'A'
kFoldGroupIndex = ceil(10 * rand(size(A,1),1));

Now, there are (approximately) an equal number of integers 1, 2, ... 10, making train/test in k-fold cross-validation easy.

-Predictor
http://will.dwinnell.com

249 posts.
Wednesday 04 February, 09:26
Reply
• THANKZ!

THANK U BROTHER!

You are a kind soul.Really appreciate your help!

34 posts.
Thursday 05 February, 02:07
Reply
• Random data

Dear Sir,

I have the same question. I have a matrix of data with the dimension 8320*4 (8320 samples in rows and 4 columns of variables). I run the code but it didn’t work. Let me write the results step by step:

I want to enter 5000 random rows of the matrix to ANN. So:

>>TrainN= 5000

>> size (A)

ans =

8320 4

>> (size(A,2))'

ans =

4

>>TrainRows = randperm(size(A,2))'

TrainRows =

4

3

2

1

>>TrainRows = TrainRows(1:TrainN)

??? Index exceeds matrix dimensions.

Could you please lead me how can I extract 5000 random rows for training and keep the rest for the test?

With kind regards

Abbas Jafari

1 posts.
Tuesday 04 January, 05:42
Reply
• Train / Test Extraction via MATLAB

Sorry: that should be size(A,1). I fixed it in previous messages in this thread.

-Will Dwinnell
http://will.dwinnell.com

249 posts.
Tuesday 04 January, 20:15
Reply