<s> from model import * <EOL> from data_api import * <EOL> import sys <EOL> X = prepare_experiment_data ( dataset = "<STR_LIT>" , CV = <NUM_LIT:0> ) <EOL> params = cPickle . load ( open ( sys . argv [ <NUM_LIT:1> ] , "<STR_LIT:r>" ) ) <EOL> R = range ( <NUM_LIT:11> ) <EOL> networks = createNetworks ( entity_matrix = X [ "<STR_LIT:E>" ] , embedding_matrix = params [ "<STR_LIT>" ] , k = <NUM_LIT:4> , only_metric = False ) <EOL> pars = params [ "<STR_LIT>" ] <EOL> for i , n in enumerate ( networks ) : <EOL> n . load_params ( pars [ i ] ) <EOL> X_test = split_per_relation ( X [ "<STR_LIT>" ] , rel = range ( <NUM_LIT:11> ) ) <EOL> best_splits = [ ] <EOL> accs_history = [ ] <EOL> networks [ <NUM_LIT:0> ] . update_EU ( ) <EOL> for r in range ( <NUM_LIT:11> ) : <EOL> test_values = np . linspace ( - <NUM_LIT> , <NUM_LIT> , num = <NUM_LIT:50> ) <EOL> f_eval = theano . function ( networks [ r ] . inputs , networks [ r ] . f_prop ( ) ) <EOL> accuracies = [ ] <EOL> for split in test_values : <EOL> results_pos = f_eval ( X_test [ r ] [ : , <NUM_LIT:0> : <NUM_LIT:3> ] ) . reshape ( - <NUM_LIT:1> ) <EOL> results_neg = f_eval ( X_test [ r ] [ : , [ <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:4> ] ] ) . reshape ( - <NUM_LIT:1> ) <EOL> accuracies . append ( ( sum ( results_pos > split ) + sum ( results_neg < split ) ) / ( <NUM_LIT:2> * float ( X_test [ r ] . shape [ <NUM_LIT:0> ] ) ) ) <EOL> best_splits . append ( test_values [ np . argmax ( accuracies ) ] ) <EOL> accs_history . append ( accuracies ) <EOL> print ( best_splits ) <EOL> accs = [ ] <EOL> global_acc = <NUM_LIT:0> <EOL> for r in range ( <NUM_LIT:11> ) : <EOL> f_eval = theano . function ( networks [ r ] . inputs , networks [ r ] . f_prop ( ) ) <EOL> results_pos = f_eval ( X_test [ r ] [ : , <NUM_LIT:0> : <NUM_LIT:3> ] ) . reshape ( - <NUM_LIT:1> ) <EOL> results_neg = f_eval ( X_test [ r ] [ : , [ <NUM_LIT:3> , <NUM_LIT:1> , <NUM_LIT:4> ] ] ) . reshape ( - <NUM_LIT:1> ) <EOL> cnt = ( sum ( results_pos > best_splits [ r ] ) + sum ( results_neg < best_splits [ r ] ) ) <EOL> accs . append ( cnt / ( <NUM_LIT:2> * float ( X_test [ r ] . shape [ <NUM_LIT:0> ] ) ) ) <EOL> global_acc += cnt <EOL> global_acc = global_acc / ( <NUM_LIT:2> * float ( X [ "<STR_LIT>" ] . shape [ <NUM_LIT:0> ] ) ) <EOL> print ( global_acc ) <EOL> print ( accs ) </s>
