"_data/mean_shape.pkl"
    w, h = 50, 50
    bx, dx = 0.5, 0.001
    border_x = bx
    tags_oc = None
    with open(path_test, 'r') as f:
        l_samples = pkl.load(f)
    input = T.fmatrix("x_input")
    output = T.fmatrix("y_output")

    ds = FaceDataset()
    x, y, l_infos = ds.sample_from_list_to_test(l_samples, w, h)
    ts_batch_size = 1000
    x, y, l_infos, tags_oc = artificiel_occlusion(x, y, l_infos)

    list_minibatchs_vl = split_data_to_minibatchs_eval(
        {"x": x, "y":  y}, ts_batch_size)
    fold_exp = "../../exps/" + sys.argv[1]
    with open(fold_exp+"/model.pkl", 'r') as f:
        stuff = pkl.load(f)
        layers_infos, params_vl = stuff["layers_infos"], stuff["params_vl"]
        print layers_infos
        tag = stuff["tag"]
        dropout = stuff["dropout"]
        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")

    eval_fn = get_eval_fn(model)
예제 #2
0
id_deep_conv_ae = id_deep_conv_ae.replace("(", "")
id_deep_conv_ae = id_deep_conv_ae.replace(")", "")
print len(id_deep_conv_ae), id_deep_conv_ae
path_ini_params_deep_conv_ae = init_w_deep_conv_ae_path +\
    "deep_conv_ae_init_" + id_deep_conv_ae + ".pkl"
if not os.path.isfile(path_ini_params_deep_conv_ae):
    deep_conv_ae.save_params(path_ini_params_deep_conv_ae)
else:
    deep_conv_ae.set_params_vals(path_ini_params_deep_conv_ae)

with open(path_valid, 'r') as f:
    l_samples_vl = pkl.load(f)
    # convert to 3D
    nbr_xx = l_samples_vl["x"].shape[0]
    l_samples_vl["x"] = l_samples_vl["x"].reshape((nbr_xx, 1, h, w))
list_minibatchs_vl = split_data_to_minibatchs_eval(l_samples_vl, vl_batch_size)
max_epochs = int(1000)

lr_vl = 1e-4
lr = sharedX_value(lr_vl, name="lr")
optimizer = "momentum"
if optimizer == "adadelta":
    updater = AdaDelta(decay=0.95)
elif optimizer == "momentum":
    updater = Momentum(0.9,
                       nesterov_momentum=True,
                       imagenet=False,
                       imagenetDecay=5e-4,
                       max_colm_norm=False)
else:
    raise ValueError("Optimizer not recognized.")
예제 #3
0
    # number of the hidden layer just before the output ae. Default: None
    id_code = None
    model = ModelMLP(layers, input, l1_reg=0., l2_reg=0., reg_bias=False,
                     dropout=dropout, id_code=id_code)
    aes_in = []
    aes_out = []
    if id_code is not None:
        assert aes_out != []
    # Train
    # Data
    tr_batch_size = 10
    vl_batch_size = 8000

    with open(path_valid, 'r') as f:
        l_samples_vl = pkl.load(f)
    list_minibatchs_vl = split_data_to_minibatchs_eval(
        l_samples_vl, vl_batch_size)
    max_epochs = int(1000)
    lr_vl = 1e-3
    lr = sharedX_value(lr_vl, name="lr")
    # cost weights
    separate = True
    l_in = [sharedX_value(0., name="l_in"), sharedX_value(0.0, name="l_in2")]
    l_out = [sharedX_value(0., name="l_out")]
    l_sup = sharedX_value(1., name="l_sup")
    l_code = sharedX_value(0.0, name="l_code")
    if not separate:
        assert l_sup.get_value() + l_in.get_value() + l_out.get_value() == 1.
    if l_in[0].get_value() != 0. and aes_in == []:
        raise ValueError("You setup the l_in but no aes in found.")
    if l_out[0].get_value() != 0. and aes_out == []:
        raise ValueError("You setup the l_out but no aes out found.")
예제 #4
0
    #    x, y, l_infos = ds.sample_from_list_to_test(l_samples, w, h)
    ts_batch_size = 1000
    with open("../../inout/data/face/" + faceset + "_data/test.pkl",
              'r') as fx:
        dumped = pkl.load(fx)
    with open("../../inout/data/face/" + faceset + "_data/valid.pkl",
              'r') as fx:
        dumped_vl = pkl.load(fx)
    x = dumped["x"]
    y = dumped["y"]
    nfids = dumped["nfids"]
    bboxesT = dumped["bboxesT"]
    bboxesT_original = dumped["bboxesT_original"]
    base_name = dumped["base_name"]
    list_minibatchs_vl = split_data_to_minibatchs_eval({
        "x": x,
        "y": y
    }, ts_batch_size)
    fold_exp = "../../exps/" + sys.argv[1]
    with open(fold_exp + "/model.pkl", 'r') as f:
        stuff = pkl.load(f)
        layers_infos, params_vl = stuff["layers_infos"], stuff["params_vl"]
        print layers_infos
        tag = stuff["tag"]
        dropout = stuff["dropout"]
        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")