Example #1
0
    print("\n")
    print("Loading model parameters from:", dump_file)
    with open(dump_file, 'rb') as fp:
         params = pickle.load(fp)
    if isinstance(params[0], list):
        # old redundant dump
        for i_layer, layer in enumerate(layers):
            lasagne.layers.set_all_param_values(layer, params[i_layer])
    else:
        # non-redundant dump
        lasagne.layers.set_all_param_values(layers, params)

    # select data
    print("\nLoading data...")
    data = select_data(args.data, args.train_split, args.config, args.seed, test_only=True)

    print("\nCompiling prediction functions...")
    l_view1, l_view2, l_v1latent, l_v2latent = layers

    input_1 = input_2 = [l_view1.input_var, l_view2.input_var]
    compute_v1_latent = theano.function(inputs=input_1,
                                        outputs=lasagne.layers.get_output(l_v1latent, deterministic=True))
    compute_v2_latent = theano.function(inputs=input_2,
                                        outputs=lasagne.layers.get_output(l_v2latent, deterministic=True))

    # iterate test data
    print("Evaluating on test set...")

    # compute output on test set
    eval_set = 'test'
Example #2
0
    # load model parameters
    if args.estimate_UV:
        model.EXP_NAME += "_est_UV"
    out_path = os.path.join(os.path.join(EXP_ROOT), model.EXP_NAME)
    dump_file = 'params.pkl' if args.tag is None else 'params_%s.pkl' % args.tag
    dump_file = os.path.join(out_path, dump_file)

    print("\n")
    print("Loading model parameters from:", dump_file)
    with open(dump_file, 'r') as fp:
        params = pickle.load(fp)
    lasagne.layers.set_all_param_values(layers, params)

    print("\nLoading data...")
    data = select_data(args.data, seed=args.seed)

    print("\nCompiling prediction functions...")
    l_view1, l_view2, l_v1latent, l_v2latent = layers

    input_1 = input_2 = [l_view1.input_var, l_view2.input_var]

    compute_v1_latent = theano.function(inputs=input_1,
                                        outputs=lasagne.layers.get_output(
                                            l_v1latent, deterministic=True))
    compute_v2_latent = theano.function(inputs=input_2,
                                        outputs=lasagne.layers.get_output(
                                            l_v2latent, deterministic=True))

    print("Evaluating on test set...")
Example #3
0
    print("\n")
    print("Loading model parameters from:", dump_file)
    with open(dump_file, 'r') as fp:
         params = pickle.load(fp)
    lasagne.layers.set_all_param_values(layers, params)

    # reset model parameter file
    model.EXP_NAME += "_est_UV"
    out_path = os.path.join(os.path.join(EXP_ROOT), model.EXP_NAME)
    if not os.path.exists(out_path):
        os.mkdir(out_path)
    dump_file = os.path.join(out_path, dump_file_name)

    # select data
    print("\nLoading data...")
    data = select_data(args.data, args.train_split, args.config, args.seed)

    print("\nCompiling prediction functions...")
    l_view1, l_view2, l_v1latent, l_v2latent = layers

    # get network input variables
    input_1, input_2 = [l_view1.input_var], [l_view2.input_var]

    # get cca layer input
    for l in lasagne.layers.helper.get_all_layers(l_v1latent):
        if isinstance(l, CCALayer1) or isinstance(l, CCALayer2):
            print("CCALayer found!")
            cca_layer = l
            l_v1_cca = cca_layer.input_layers[0]
            l_v2_cca = cca_layer.input_layers[1]
            break