@@ -0,0 +1,1934 @@
+__author__ = 'Guanhua, Joms'%0Afrom scipy.io import loadmat%0Afrom numpy import vstack%0A%0A%0Adef merge_um_umm_uu(key, UM, num_imgs_um, UMM, num_imgs_umm, UU, num_imgs_uu):%0A    ''' Merges the data set in the 3 .mat files specified by the key - %0A        feature_vector or target.%0A        (Merges the data or the targets in the 3 .mat files and returns it.)%0A    '''%0A    %0A    um = vstack(((UM%5Bkey%5D%5B:,i%5D)%5B0%5D for i in range(num_imgs_um)))%0A    umm = vstack(((UMM%5Bkey%5D%5B:,i%5D)%5B0%5D for i in range(num_imgs_umm)))%0A    uu = vstack(((UU%5Bkey%5D%5B:,i%5D)%5B0%5D for i in range(num_imgs_uu)))%0A    %0A    d = vstack((um, umm, uu))%0A    %0A    return d%0A    %0A%0Adef split_d(d):%0A    ''' Splits the merged data or targets as specified by d into training, %0A        validation, and test data sets.%0A        Returns the tuple consisting of training, validation and testing set.%0A    '''%0A%0A    train_size = int (0.6 * len(d))%0A    validation_size = int (0.1 * len(d))%0A%0A    train_d = d%5B0:train_size%5D%0A    validation_d = d%5Btrain_size:(train_size+validation_size)%5D%0A    test_d = d%5B(train_size+validation_size):%5D%0A    %0A    return (train_d, validation_d, test_d)%0A    %0A%0Adef split_main():%0A    ''' Returns a tuple of (training data, training targets, validation data, validation targets, %0A        test data, test targets)%0A    '''%0A    %0A    UM = loadmat('um_data')%0A    UMM = loadmat('umm_data')%0A    UU = loadmat('uu_data')%0A    num_imgs_um = UM%5B'feature_vector'%5D.shape%5B1%5D%0A    num_imgs_umm = UMM%5B'feature_vector'%5D.shape%5B1%5D%0A    num_imgs_uu = UU%5B'feature_vector'%5D.shape%5B1%5D%0A    %0A    data = merge_um_umm_uu('feature_vector', UM, num_imgs_um, UMM, num_imgs_umm, UU, num_imgs_uu)%0A    train_data, validation_data, test_data =  split_d(data)%0A    %0A    targets = merge_um_umm_uu('target', UM, num_imgs_um, UMM, num_imgs_umm, UU, num_imgs_uu)%0A    train_tgts, validation_tgts, test_tgts =  split_d(targets)   %0A    %0A    return (train_data, train_tgts, validation_data, validation_tgts, test_data, test_tgts)%0A%0A%0A%0A%0A    %0A

Create split.py