示例#1
0
        if pre_test_probs == None:
            pre_test_probs = prmlps[i].pretrain_test_probs
        else:
            pre_test_probs = numpy.column_stack((pre_test_probs, prmlps[i].pretrain_test_probs))
    print "In the end the test score is %f " % (numpy.mean(test_scores))
    return pre_test_probs

if __name__=="__main__":
    x = T.matrix('x')
    dataset = "/data/lisa/data/pentomino/pentomino64x64_4k_pre.npy"
    ds = Dataset()

    print "starting pretrain"

    ds.setup_pretraining_dataset(data_path=dataset)
    
    train_set_patches, train_set_pre, train_set_labels = ds.Xtrain_patches, ds.Xtrain_presences, ds.Ytrain
    test_set_patches, test_set_pre, test_set_labels = ds.Xtest_patches, ds.Xtest_presences, ds.Ytest

    prmlps = [PreMLP(x) for each in xrange(64)]
    
    print "starting pretest"
    pre_train_probs = train_prmlp(prmlps, train_set_patches, train_set_pre)
    pre_test_probs = test_prmlp(prmlps, test_set_patches, test_set_pre)

    post_mlp = PosttrainMLP(x, n_in=64*11, n_hidden=200, n_out=10)

    post_mlp.posttrain(data=pre_train_probs, labels=train_set_labels, batch_size=80)
    post_mlp.posttest(data=pre_test_probs, labels=test_set_labels)

示例#2
0
    print "starting pretrain"

    ds.setup_pretraining_dataset(data_path=dataset)

    train_set_patches, train_set_pre, train_set_labels = ds.Xtrain_patches, ds.Xtrain_presences, ds.Ytrain
    test_set_patches, test_set_pre, test_set_labels = ds.Xtest_patches, ds.Xtest_presences, ds.Ytest

    prmlp = PreMLP(x, n_epochs=2)
    post_mlp = PosttrainMLP(x, n_in=64 * 11, n_hidden=400, n_out=10)

    print "starting pre-training"
    pre_train_probs = train_prmlp(prmlp, train_set_patches, train_set_pre)

    print "starting the pre-testing"
    pre_test_probs = test_prmlp(prmlp, test_set_patches, test_set_pre)

    print "starting post-training"
    post_mlp.posttrain(learning_rate=0.001,
                       data=pre_train_probs,
                       n_epochs=4,
                       labels=train_set_labels,
                       batch_size=60,
                       save_costs_file=True,
                       cost_type="negativelikelihood")

    print "starting post-testing"
    post_mlp.posttest(data=pre_test_probs,
                      labels=test_set_labels,
                      save_costs_file=True)
示例#3
0
    print "starting pretrain"

    ds.setup_pretraining_dataset(data_path=dataset)

    train_set_patches, train_set_pre, train_set_labels = ds.Xtrain_patches, ds.Xtrain_presences, ds.Ytrain
    test_set_patches, test_set_pre, test_set_labels = ds.Xtest_patches, ds.Xtest_presences, ds.Ytest

    prmlp = PreMLP(x, n_epochs=2)
    post_mlp = PosttrainMLP(x, n_in=64 * 11, n_hidden=400, n_out=10)

    print "starting pre-training"
    pre_train_probs = train_prmlp(prmlp, train_set_patches, train_set_pre)

    print "starting the pre-testing"
    pre_test_probs = test_prmlp(prmlp, test_set_patches, test_set_pre)

    print "starting post-training"
    post_mlp.posttrain(
        learning_rate=0.001,
        data=pre_train_probs,
        n_epochs=4,
        labels=train_set_labels,
        batch_size=60,
        save_costs_file=True,
        cost_type="negativelikelihood",
    )

    print "starting post-testing"
    post_mlp.posttest(data=pre_test_probs, labels=test_set_labels, save_costs_file=True)