Пример #1
0
def run(data_name, num_train, num_test, Phi,
        depth, widths, lc_w_range, shift_w_range,
        optim_name, optim_args,
        num_epochs, batch_size, chkpt_freq):
    id = get_info()
    identifier_id = '%s%s' % (identifier, id)
    train_data, test_data = load_data(data_name, num_train, num_test)
    train_ll, test_ll = load_log_ll(data_name, num_train, num_test)

    print('Computing ground truth manually because tagged log likelihood is wrong')
    from phi_listing import ClaytonPhi
    gt_phi = ClaytonPhi(torch.tensor(5.))
    cop = Copula(gt_phi)
    train_ll = -torch.log(cop(train_data, mode='pdf'))
    test_ll = -torch.log(cop(test_data, mode='pdf'))

    print('train_ll', torch.mean(train_ll))
    print('test_ll', torch.mean(test_ll))

    print('Train ideal ll:', torch.mean(train_ll))
    print('Test ideal ll:', torch.mean(test_ll))

    phi = Phi(depth, widths, lc_w_range, shift_w_range)
    net = Copula(phi)
    expt(train_data, test_data, net, optim_name,
         optim_args, identifier_id, num_epochs, batch_size, chkpt_freq)
Пример #2
0
def run(x_index, y_index,
        x_flip, y_flip,
        Phi,
        depth, widths, lc_w_range, shift_w_range,
        optim_name, optim_args,
        num_epochs, batch_size, chkpt_freq,
        frac_rand):
    id = get_info()
    identifier_id = '%s%s' % (identifier, id)

    train_data = X_train[:, [x_index, y_index]]
    train_data = add_train_random_noise(train_data,
                                        int(train_data.shape[0]*frac_rand))
    test_data = X_test[:, [x_index, y_index]]

    if x_flip:
        train_data[:, 0] = 1-train_data[:, 0]
        test_data[:, 0] = 1-test_data[:, 0]

    if y_flip:
        train_data[:, 1] = 1-train_data[:, 1]
        test_data[:, 1] = 1-test_data[:, 1]

    phi = Phi(depth, widths, lc_w_range, shift_w_range)
    net = Copula(phi)
    expt(train_data, test_data, net, optim_name,
         optim_args, identifier_id, num_epochs, batch_size, chkpt_freq)
Пример #3
0
def gen_data(phi,
             ndims,
             N,
             seed):
    torch.set_default_tensor_type(torch.DoubleTensor)
    net = Copula(phi)

    s = sample(net, ndims, N, seed=seed)
    log_ll = -torch.log(net(s, 'pdf'))

    print('mean log_ll:', torch.mean(log_ll))

    plot_samples(s)
    return s, log_ll
Пример #4
0
def run(Phi, initial_theta, optim_name, optim_args, num_epochs, batch_size,
        chkpt_freq, frac_rand):
    id = get_info()
    identifier_id = '%s%s' % (identifier, id)

    train_data = X_train
    train_data = add_train_random_noise(train_data,
                                        int(X_train.shape[0] * frac_rand))
    test_data = X_test

    phi = Phi(torch.tensor(initial_theta))
    net = Copula(phi)
    expt(train_data, test_data, net, optim_name, optim_args, identifier_id,
         num_epochs, batch_size, chkpt_freq)
Пример #5
0
def run(Phi, depth, widths, lc_w_range, shift_w_range, optim_name, optim_args,
        num_epochs, batch_size, chkpt_freq, frac_rand):
    id = get_info()
    identifier_id = '%s%s' % (identifier, id)

    train_data = X_train
    train_data = add_train_random_noise(train_data,
                                        int(X_train.shape[0] * frac_rand))
    test_data = X_test

    phi = Phi(depth, widths, lc_w_range, shift_w_range)
    net = Copula(phi)
    expt(train_data, test_data, net, optim_name, optim_args, identifier_id,
         num_epochs, batch_size, chkpt_freq)
Пример #6
0
def run(data_name, num_train, num_test, Phi, depth, widths, lc_w_range,
        shift_w_range, optim_name, optim_args, num_epochs, batch_size,
        chkpt_freq):
    id = get_info()
    identifier_id = '%s%s' % (identifier, id)
    train_data, test_data = load_data(data_name, num_train, num_test)
    train_ll, test_ll = load_log_ll(data_name, num_train, num_test)

    print('Train ideal ll:', torch.mean(train_ll))
    print('Test ideal ll:', torch.mean(test_ll))

    phi = Phi(depth, widths, lc_w_range, shift_w_range)
    net = Copula(phi)
    expt(train_data, test_data, net, optim_name, optim_args, identifier_id,
         num_epochs, batch_size, chkpt_freq)