GithubHelp home page GithubHelp logo

otiliastr / coper Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 7.0 38.55 MB

Contextual Parameter Generation for Knowledge Graph Link Prediction

Python 55.21% Dockerfile 0.19% Makefile 0.03% Shell 1.13% Jupyter Notebook 43.45%

coper's People

Contributors

eaplatanios avatar gstoica27 avatar otiliastr avatar todpole3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

coper's Issues

error occurs when model predicted

When I execute command —— !cd coper-master/CoPER_MINERVA/ && bash ./experiment.sh configs/umls.sh --inference 0
error occurs:
Memory allocated before eval data loading: 1.02944768
HIIIII
652 triples loaded from data/umls/dev.triples
661 triples loaded from data/umls/test.triples
Memory allocated after eval data loading: 1.02944768
0% 0/326 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/content/coper-master/CoPER_MINERVA/src/experiments.py", line 830, in
run_experiment(args)
File "/content/coper-master/CoPER_MINERVA/src/experiments.py", line 813, in run_experiment
inference(lf)
File "/content/coper-master/CoPER_MINERVA/src/experiments.py", line 369, in inference
pred_scores = lf.forward(dev_data, verbose=False)
File "/content/coper-master/CoPER_MINERVA/src/learn_framework.py", line 253, in forward
pred_score = self.predict(mini_batch, verbose=verbose)
File "/content/coper-master/CoPER_MINERVA/src/rl/graph_search/pg.py", line 226, in predict
pn, e1, r, e2, kg, self.num_rollout_steps, self.beam_size)
File "/content/coper-master/CoPER_MINERVA/src/rl/graph_search/beam_search.py", line 168, in beam_search
pn.update_path(action, kg, offset=action_offset)
File "/content/coper-master/CoPER_MINERVA/src/rl/graph_search/pn.py", line 257, in update_path
offset_path_history(self.path, offset)
File "/content/coper-master/CoPER_MINERVA/src/rl/graph_search/pn.py", line 235, in offset_path_history
new_tuple = tuple([_x[offset, :, :] for _x in x])
File "/content/coper-master/CoPER_MINERVA/src/rl/graph_search/pn.py", line 235, in
new_tuple = tuple([_x[offset, :, :] for _x in x])
IndexError: tensors used as indices must be long, byte or bool tensors

type of elements in offset is float, how can I solve it, anyone can help

Potentially incorrect evaluation on FB15k-237? Why only tail prediction?

Hi

As pointed out by @LinXueyuanStdio in #6 , during evaluation, scores are only calculate in one direction: h, r to t. This results in unusually high scores (for eg. they get very high scores with TransE, a 2013 model), for both Coper as well as baselines, and hence these numbers cannot be compared with other papers (almost all papers use the average of head and tail prediction).

Do you have numbers with the correct evaluation as well, ie both head and tail prediction averaged?

Thanks

The result of WN18RR is different from the paper.

Dear Prof:
I can't get the result of CoPER-ConvE on the dataset WN18RR. The parameters I used during the training process are just the parameters from the source file named 'config_WN18RR_cpg.yaml'.
If there is something I missed, could you please point it out? Thanks a lot.

I reproduce the result of ConvE on the FB15k-237, but...

Hello @otiliastr , thanks for sharing your nice code! Your job has inspired me a lot. I love it.

I run the code in CoPER_ConvE, and I have got ~60% of ConvE and ~62% of CoPER-ConvE on the FB15k-237 (hits@10).
Everything is OK.
However , when I rewrite it using PyTorch, I can only get ~50% of ConvE and ~53% of CoPER-ConvE on the FB15k-237 (hits@10).
I have read the paper carefully. And I have implemented the negative sampling the same as the paper said. But it shows that the negative sampling takes no effect. It keeps ~53% of CoPER-ConvE on the FB15k-237 (hits@10) with and without negative sampling.
So I believe the negative sampling strategy is not the key trick.
It is very very very strange that I can reproduce the result which is written by Tensorflow1.x while I couldn't reproduce it by PyTorch!
I will appreciate it if you can give more advice.

How I implement negative sampling:

  1. build map : { (h, r)-> [t1,t2,...,tn] }. Here (h, r, t1), (h,r,t2),...,(h,r,tn) are triples from training set. h,r,t the index of head, relation and tail.
  2. build target ids matrix of shape BatchSize x SamplingWindowSize and target scores matrix of the same shape as target ids.
    for BatchSize=2, SamplingWindowSize=3, training set { (1,1,2),(1,1,3),(2,1,3) }, entity set {1,2,3,4}, relation set {1,2}, the sample is
    target ids=[ [2,3,4], [3,1,2] ], target scores=[ [1,1,0], [1,0,0] ] for batch [ [1,1], [2,1] ]
  3. train using target ids and target socres.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.