()
Loads the training data set including X and y and saves it to .npy file.
Loads the training data set including X and y and saves it to .npy file.
Loads the training data set including X and y and saves it to . npy file .
def write_train_npy():
    """
    Loads the training data set including X and y and saves it to .npy file.
    """
    print('-'*50)
    print('Writing training data to .npy file...')
    print('-'*50)

    study_ids, images = load_images('data/train')  # load images and their ids
    studies_to_results = map_studies_results()  # load the dictionary of studies to targets
    X = []
    y = []

    for study_id in study_ids:
        study = images[study_id]
        outputs = studies_to_results[study_id]
        for i in range(study.shape[0]):
            X.append(study[i, :, :, :])
            y.append(outputs)

    X = np.array(X, dtype=np.uint8)
    y = np.array(y)
    np.save('data/X_train.npy', X)
    np.save('data/y_train.npy', y)
    print('Done.')
def write_train_npy ( ) : print ( '-' * 50 ) print ( 'Writing training data to .npy file...' ) print ( '-' * 50 ) study_ids , images = load_images ( 'data/train' ) # load images and their ids studies_to_results = map_studies_results ( ) # load the dictionary of studies to targets X = [ ] y = [ ] for study_id in study_ids : study = images [ study_id ] outputs = studies_to_results [ study_id ] for i in range ( study . shape [ 0 ] ) : X . append ( study [ i , : , : , : ] ) y . append ( outputs ) X = np . array ( X , dtype = np . uint8 ) y = np . array ( y ) np . save ( 'data/X_train.npy' , X ) np . save ( 'data/y_train.npy' , y ) print ( 'Done.' )