src/core/data.py
def load_data(params):
    '''
    Convenience function: reads from disk, downloads, or generates the data specified in params
    '''
    if params['dset'] == 'reuters':
        with h5py.File('../../data/reuters/reutersidf_total.h5', 'r') as f:
            x = np.asarray(f.get('data'), dtype='float32')
            y = np.asarray(f.get('labels'), dtype='float32')

            n_train = int(0.9 * len(x))
            x_train, x_test = x[:n_train], x[n_train:]
            y_train, y_test = y[:n_train], y[n_train:]
    elif params['dset'] == 'mnist':
        x_train, x_test, y_train, y_test = get_mnist()
    elif params['dset'] == 'cc':
        x_train, x_test, y_train, y_test = generate_cc(params.get('n'), params.get('noise_sig'), params.get('train_set_fraction'))
        x_train, x_test = pre_process(x_train, x_test, params.get('standardize'))
    else:
        raise ValueError('Dataset provided ({}) is invalid!'.format(params['dset']))

    return x_train, x_test, y_train, y_test

    Convenience function: reads from disk, downloads, or generates the data specified in params
    
Convenience function: reads from disk, downloads, or generates the data specified in params
Convenience function : reads from disk downloads or generates the data specified in params
def load_data(params):
    if params['dset'] == 'reuters':
        with h5py.File('../../data/reuters/reutersidf_total.h5', 'r') as f:
            x = np.asarray(f.get('data'), dtype='float32')
            y = np.asarray(f.get('labels'), dtype='float32')
            n_train = int(0.9 * len(x))
            x_train, x_test = x[:n_train], x[n_train:]
            y_train, y_test = y[:n_train], y[n_train:]
    elif params['dset'] == 'mnist':
        x_train, x_test, y_train, y_test = get_mnist()
    elif params['dset'] == 'cc':
        x_train, x_test, y_train, y_test = generate_cc(params.get('n'), params.get('noise_sig'), params.get('train_set_fraction'))
        x_train, x_test = pre_process(x_train, x_test, params.get('standardize'))
    else:
        raise ValueError('Dataset provided ({}) is invalid!'.format(params['dset']))
    return x_train, x_test, y_train, y_test
def load_data ( params ) : if params [ 'dset' ] == 'reuters' : with h5py . File ( '../../data/reuters/reutersidf_total.h5' , 'r' ) as f : x = np . asarray ( f . get ( 'data' ) , dtype = 'float32' ) y = np . asarray ( f . get ( 'labels' ) , dtype = 'float32' ) n_train = int ( 0.9 * len ( x ) ) x_train , x_test = x [ : n_train ] , x [ n_train : ] y_train , y_test = y [ : n_train ] , y [ n_train : ] elif params [ 'dset' ] == 'mnist' : x_train , x_test , y_train , y_test = get_mnist ( ) elif params [ 'dset' ] == 'cc' : x_train , x_test , y_train , y_test = generate_cc ( params . get ( 'n' ) , params . get ( 'noise_sig' ) , params . get ( 'train_set_fraction' ) ) x_train , x_test = pre_process ( x_train , x_test , params . get ( 'standardize' ) ) else : raise ValueError ( 'Dataset provided ({}) is invalid!' . format ( params [ 'dset' ] ) ) return x_train , x_test , y_train , y_test
Convenience function: reads from disk, downloads, or generates the data specified in params
Convenience function : reads from disk downloads or generates the data specified in params
'''
    Convenience function: reads from disk, downloads, or generates the data specified in params
    '''
params