Beispiel #1
0
        TRAIN_RESULT_FOLDER, 'cv_' + model_name + '_train_' + dataset_name)

###################################
## OUTPUT PATH
#if args.test is True:
#    config.TRAIN_RESULT_PATH = r'/home/ys587/tensorflow3/__ExptResult/cv_validate_test_'+model_name
#else:
#    config.TRAIN_RESULT_PATH = r'/home/ys587/tensorflow3/__ExptResult/cv_validate_'+model_name
#    #config.TRAIN_RESULT_PATH = r'/tmp/x-validate' #<<<=== TEST

if not os.path.exists(config.TRAIN_RESULT_PATH):
    os.makedirs(config.TRAIN_RESULT_PATH, exist_ok=True)

##################################
# prepare training dta
label, feature = prepare_truth_data(config)
##random.seed(a = 29) # seed to randomly sample of training data

# train the classifier
#cvscores = net_train_cross_validation(feature, label, model, config)
average_precision, auc_ROC, F1_score = net_train_cross_validation(
    feature, label, model, config)
#net_train(feature, label, model, config)

#np.savetxt(os.path.join(config.TRAIN_RESULT_PATH, 'average_precision.txt'), average_precision, delimiter=",", fmt='%.6f')
#np.savetxt(os.path.join(config.TRAIN_RESULT_PATH, 'auc_ROC.txt'), auc_ROC, delimiter=",", fmt='%.6f')
#np.savetxt(os.path.join(config.TRAIN_RESULT_PATH, 'F1_score.txt'), F1_score, delimiter=",", fmt='%.6f')

with open(os.path.join(config.TRAIN_RESULT_PATH, 'result.txt'), 'w') as f:
    with redirect_stdout(f):
        print('Average Precision Score:')
Beispiel #2
0
            TRAIN_RESULT_FOLDER,
            'cv_TEST_' + model_name + '_train_' + dataset_name + '_augment')
    else:
        config.TRAIN_RESULT_PATH = os.path.join(
            TRAIN_RESULT_FOLDER,
            'cv_TEST_' + model_name + '_train_' + dataset_name)
elif args.augment is True:
    config.TRAIN_RESULT_PATH = os.path.join(
        TRAIN_RESULT_FOLDER,
        'cv_' + model_name + '_train_' + dataset_name + '_augment')
else:
    #config.TRAIN_RESULT_PATH = r'/home/ys587/tensorflow3/__ExptResult/cv_validate_'+model_name
    config.TRAIN_RESULT_PATH = os.path.join(
        TRAIN_RESULT_FOLDER, 'cv_' + model_name + '_train_' + dataset_name)

label_in, feature_in = prepare_truth_data(config)
#feature_in = feature_in.reshape(feature_in.shape[0], config.IMG_X, config.IMG_Y, 1)
feature_in = feature_in.reshape(feature_in.shape[0], config.IMG_T,
                                config.IMG_F, 1)
#label0 = keras.utils.to_categorical(label_in, config.NUM_CLASSES)

##################################
if config.RECURR == True:
    feature_in = np.squeeze(feature_in)

func_model_generate = globals()[config.MODEL]
model_name_format = 'epoch_{epoch:02d}_F1_{F1_Class:.4f}.hdf5'

# evaluate data
# truth data:
truth_folder = os.path.join(DATA_DIR, 'DCL_St_Andrew/Sound_3_days_seltab')