查看单个帖子
旧 2019-11-23, 20:41   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Separate matrix of column vectors into training and testing data in MATLAB

I'm currently doing a project in MATLAB using the MNIST data set. I have a training data set of n = 50000, represented by a matrix of 784 x 50000 (50000 column vectors of size 784).

I am trying to separate my training and testing data (70-30, respectively), but the method I am using is a bit wordy and brute force for my liking. Being that this is MATLAB, I'm sure there has got to be a better way. The code I have been using is listed below. I'm brand new to MATLAB so please help! Thanks :)

% MNIST - data loads into trn and trnAns, representing% the input vectors and the desired output vectors, respectivelyload('Data/mnistTrn.mat');mnist_train = zeros(784, 35000);mnist_train_ans = zeros(10, 35000);mnist_test = zeros(784, 15000);mnist_test_ans = zeros(10, 15000);indexes = zeros(1,50000);for i = 1:50000 indexes(i) = i;endindexes(randperm(length(indexes)));for i = 1:50000 if i
poster 当前离线   回复时引用此帖