"tr_pure_cost_mb": [], "error_tr": [], "error_vl": [],
                   "error_tr_mb": [], "error_vl_mb": [], "code_cost_mb": [],
                   "best_epoch": 0, "best_mb": 0}
    # tag
    if aes_in == [] and aes_out == []:
        tag = "sup"
    elif aes_in != [] and aes_out == []:
        tag = "sup + in"
    elif aes_in == [] and aes_out != []:
        tag = "sup + out"
    elif aes_in != [] and aes_out != []:
        tag = "sup + in + out"

    tag += ", data: " + faceset + " " + id_data
    # First evaluation on valid
    error_mn, _ = evaluate_model(list_minibatchs_vl, eval_fn)
    vl_error_begin = np.mean(error_mn)

    shutil.copy(inspect.stack()[0][1], fold_exp)
    l_ch_tr_vl = []
    for ch in l_ch_tr:
        with open(ch, 'r') as f:
            l_samples = pkl.load(f)
        l_ch_tr_vl.append(l_samples)

    stop = False
    while i < max_epochs:
        stop = (i == max_epochs - 1)
        stats = train_one_epoch_chuncks(
            train_updates, eval_fn, l_ch_tr_vl,
            l_in, l_out, l_sup, l_code, list_minibatchs_vl,
 eval_fn = get_eval_fn(model)
 # Unit test
 unit_test(fold_exp+"/unit_imgs/", w, h, path_mean_shap, eval_fn, ds)
 # Perf mean shape.
 # TRAIN
 tr_path = "../../inout/data/face/" + faceset + "_data/ch_tr_1800_0_0_0.pkl"
 print "TRAIN EVAL:"
 with open(tr_path, 'r') as f:
     tr_data = pkl.load(f)
 list_minibatchs_train = split_data_to_minibatchs_eval(
     {"x": tr_data["x"], "y":  tr_data['y']}, ts_batch_size)
 cdf_ms, cdf0_1_ms, auc_ms = evaluate_mean_shape(path_mean_shap, l_infos,
                                                 w, h, y=tr_data['y'],
                                                 save_ims=False)
 # Evaluation
 error, output = evaluate_model(list_minibatchs_train, eval_fn)
 print "Error (MSE) model train data", np.mean(error)
 # VALID
 vl_path = "../../inout/data/face/" + faceset + "_data/valid.pkl"
 print "VALID EVAL:"
 with open(vl_path, 'r') as f:
     vl_data = pkl.load(f)
 list_minibatchs_valid = split_data_to_minibatchs_eval(
     {"x": vl_data["x"], "y":  vl_data['y']}, ts_batch_size)
 cdf_ms, cdf0_1_ms, auc_ms = evaluate_mean_shape(path_mean_shap, l_infos,
                                                 w, h, y=vl_data['y'],
                                                 save_ims=False)
 # Evaluation
 error, output = evaluate_model(list_minibatchs_valid, eval_fn)
 print "Error (MSE) model valid data", error
 # TEST
Beispiel #3
0
        rng = np.random.RandomState(23455)
        input = T.fmatrix("x_input")
        for l in layers_infos:
            l["W"], l["b"], l["rng"] = None, None, rng
        model = ModelMLP(layers_infos, input, dropout=dropout)
    model.set_params_vals(fold_exp + "/model.pkl")

    #    with open("best_model_keras.pkl", 'r') as f:
    #        keras_p = pkl.load(f)
    #    for param, param_vl in zip(model.params, keras_p):
    #        param.set_value(param_vl)
    #    cdf_ms, cdf0_1_ms, auc_ms = evaluate_mean_shape(
    #        path_mean_shap, l_infos, w, h, save_ims=False)
    # Evaluation
    eval_fn = get_eval_fn(model)
    error, output = evaluate_model(list_minibatchs_vl, eval_fn)
    # Mean shape
    with open(path_mean_shap, 'r') as f:
        mean_shape = pkl.load(f)
    test_mean_shape_y = y * 0.
    nbr_test = y.shape[0]
    for i in xrange(nbr_test):
        test_mean_shape_y[i] = mean_shape

    #  Reproject the mean shape.
    x = np.arange(0, border_x, dx)
    test_mean_shape_y_reproj = ro.reproject_shape(bboxesT, test_mean_shape_y,
                                                  nfids)
    test_mean_shape_y = ro.back_to_original_size_shapes(
        set_y=test_mean_shape_y_reproj,
        bbox=bboxesT,