malllabiisc / compgcn Goto Github PK
View Code? Open in Web Editor NEWICLR 2020: Composition-Based Multi-Relational Graph Convolutional Networks
License: Apache License 2.0
ICLR 2020: Composition-Based Multi-Relational Graph Convolutional Networks
License: Apache License 2.0
Hi,
just stated in your more recent work: https://arxiv.org/pdf/1911.03903.pdf, how you break ties when doing evaluation is important. And I wonder what tie handling method do you use in this work. It seems like TOP for me because of this line ranks = 1 + torch.argsort(torch.argsort(pred, dim=1, descending=True), dim=1, descending=False)[b_range, obj]
But I am not 100% sure. Please correct me if I misunderstood your code!
Hi,
CompGCN is really excellent work on knowledge graph completion. When it is training, The entire eigenmatrix is updated simultaneously and the batch indices were selected out in order to calculate the loss of KGC. I'm curious about if we deal with selecting out batch indices and only update the features about those entities which are selected. In this way, there will be a significant decrease in training time.
Have you ever considered this similar training method? Or what do you think of my thoughts on the training method?
Thanks a lot in advance!
Hi @svjan5 ,
Thanks very much for your amazing work, it's very interesting.
I am a little bit curious about why you pre-calculate all related node representations. In your code, in the block of message passing
and propagate()
you seem to calculate every related nodes across the whole dataset before seeing them all since you are using a mini-batch strategy. I am not sure if I am understanding it correctly?
It might not make sense to me since that there would definitely exist unseen entities which is beyond your mini-batch instances. But your aggregation seems to include all possible (sub, obj) pairs across the whole dataset by using self.edge_indexs
. Then the backpropagation will automatically update parameters for unseen obj entities.
For instance:
if your mini-batch contains:
(ent1, relation1, ent2), (ent1, relation2, ent3), (ent4, relation3, ent5)
, and in the whole dataset, there has one more ent1 related pairs:
(ent1, relation4, ent6).
In your current strategy, you aggregate (ent6+relation4, ent2+relation1, ent3+relation2) but you actually haven't seen ent6 in your mini-batch. It might not make sense to update the embedding for ent6?
Would you please give me some more details about why you do it like this?
Hi,
thanks for the code. I noticed that in your paper, you represent the results of DistMult + W-GCN in Table 4. But these results are not seen in the paper of W-GCN. I wonder where the results come from. Did you reproduce the results on your own?
Thanks.
I want to run the example given in Readme.md, but the GPU failed.
So I want to the lowest GPU needed.
It seems the GPU memory is enough, but it leads to black screen after training some epochs.
Currently, I'm not sure if it is due to my GPU is not stable enough.
Thanks.
First of all thank you very much for sharing your work. We have read your paper carefully and are very interested in your work. But there is a problem that is bothering us now. We could not find the specific parameter configuration in your paper on the WN18RR dataset. We were unable to reproduce your experimental results on WN18RR. This is very frustrating for us. Therefore seeking help from you, is it possible to provide us with similar experimental commands on the FB15k-237 dataset?
Hi, I have some problems about the function load_data in Runner .
Specifically, in line 50-76:
sr2o obviously contains the data for testing and validating.
self.data = ddict(list)
sr2o = ddict(set)
for split in ['train', 'test', 'valid']:
for line in open('./data/{}/{}.txt'.format(self.p.dataset, split)):
sub, rel, obj = map(str.lower, line.strip().split('\t'))
sub, rel, obj = self.ent2id[sub], self.rel2id[rel], self.ent2id[obj]
self.data[split].append((sub, rel, obj))
if split == 'train':
sr2o[(sub, rel)].add(obj)
sr2o[(obj, rel+self.p.num_rel)].add(sub)
self.data = dict(self.data)
self.sr2o = {k: list(v) for k, v in sr2o.items()}
for split in ['test', 'valid']:
for sub, rel, obj in self.data[split]:
sr2o[(sub, rel)].add(obj)
sr2o[(obj, rel+self.p.num_rel)].add(sub)
Then, you generate the label based on sr2o.
self.sr2o_all = {k: list(v) for k, v in sr2o.items()}
self.triples = ddict(list)
for (sub, rel), obj in self.sr2o.items():
self.triples['train'].append({'triple':(sub, rel, -1), 'label': self.sr2o[(sub, rel)], 'sub_samp': 1})
You use self.triples['train'] to obtain data_iter
self.data_iter = {
'train': get_data_loader(TrainDataset, 'train', self.p.batch_size),
'valid_head': get_data_loader(TestDataset, 'valid_head', self.p.batch_size),
'valid_tail': get_data_loader(TestDataset, 'valid_tail', self.p.batch_size),
'test_head': get_data_loader(TestDataset, 'test_head', self.p.batch_size),
'test_tail': get_data_loader(TestDataset, 'test_tail', self.p.batch_size),
}
and finally train the model.
train_iter = iter(self.data_iter['train'])
for step, batch in enumerate(train_iter):
self.optimizer.zero_grad()
sub, rel, obj, label = self.read_batch(batch, 'train')
Did I misunderstand something?
On Windows systems, the name of log file may cause the following errors
Traceback (most recent call last):
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\config.py", line 563, in configure
handler = self.configure_handler(handlers[name])
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\config.py", line 744, in configure_handler
result = factory(**kwargs)
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\__init__.py", line 1147, in __init__
StreamHandler.__init__(self, self._open())
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\__init__.py", line 1176, in _open
return open(self.baseFilename, self.mode, encoding=self.encoding)
OSError: [Errno 22] Invalid argument: 'D:\\MyCode\\Python\\CompGCN-master\\CompGCN-master\\log\\testrun_12_06_2022_11:38:39'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:/MyCode/Python/CompGCN-master/CompGCN-master/run.py", line 459, in <module>
model = Runner(args)
File "D:/MyCode/Python/CompGCN-master/CompGCN-master/run.py", line 147, in __init__
self.logger = get_logger(self.p.name, self.p.log_dir, self.p.config_dir)
File "D:\MyCode\Python\CompGCN-master\CompGCN-master\helper.py", line 49, in get_logger
logging.config.dictConfig(config_dict)
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\config.py", line 808, in dictConfig
dictConfigClass(config).configure()
File "D:\Software\Anaconda3\envs\DL_Study\lib\logging\config.py", line 570, in configure
raise ValueError('Unable to configure handler '
ValueError: Unable to configure handler 'file_handler'
Hi,
thanks for your code. Could you provide the scripts to reproduce the results in your paper? There are some parameters that I' not sure how to assign values, like num_bases
and gcn_layer
, etc.
Best regards
Hi,
I'm interested in your work, and I am wondering how to use your code for graph classification?
When i pip install all package for this project, i try to use given"python run.py...",but get "OSError:libtorch_cpu.so:cannot open shared object file : No such file or diectory",i change torchtext version from 0.7.0 to 0.5.0 as internet method, still not work.
Hi, thanks for opening such a good job first!
I want to know why do you use outgoing edges as node neighbors, instead of ingoing edges, to represent central node. And in this situation TransE model will be formulated as tail=head-relation
, which I think a little not intuitive?
Thank you very much.
Hi,
Thank you for this wonderful work! I got the following error when I ran with "-num_bases 50" (as suggested in the paper): AttributeError: 'CompGCNConvBasis' object has no attribute 'cache'. Can I just remove Lines 40 and 41 in compgcn_conv_basis.py?
Thank you very much for sharing your work!
In line 293 of the run.py file, head-batch and tail-batch correspond to (h,r,?) and(? ,r,t)? Or did I say it backwards?
Hi, thank you for the easy-to-understand code repository. As per my understanding, there is only one CompGCN update at every step, which would be similar to aggregating information from the first-hop neighbors. Did you experiment with more hops/iterations?
Thank you.
Hello dear authors,
thanks for publishing the code!
Trying out different decoders with the default parameters I observe that loss of ConvE and DistMult decoders gradually decreases (and accuracy increases), whereas for the TransE decoder default params do not work and loss/MRR fluctuate around the same point over and over (at least 50+ epochs from start). There are no TransE-specific hyperparams in the paper either, so after varying gcn_layers, gamma (10 to 100), and others, the model still does not converge.
Could you please provide us with the hyperparams for the TransE decoder?
Hi, can you share the hyperparameters for WN18RR?
This line could be changed to return torch.fft.irfftn(torch.conj(torch.fft.rfftn(a, (-1))) * torch.fft.rfftn(b, (-1)), (-1))
if your pytorch version >= 1.8.
Hi, thanks for sharing the code!
I find that after randomly breaking the adjacency matrices, the performance of CompGCN remains unchanged (0.334, DistMult+multiplication). The codes in run.py that I have changed are as follows.
for sub, rel, obj in self.data['train']:
obj = random.randint(0, self.p.num_ent)
edge_index.append((sub, obj))
edge_type.append(rel)
# Adding inverse edges
for sub, rel, obj in self.data['train']:
obj = random.randint(0, self.p.num_ent)
edge_index.append((obj, sub))
edge_type.append(rel + self.p.num_rel)
Did I have any misunderstanding about the codes?
r = self.init_rel if self.p.score_func != 'transe' else torch.cat([self.init_rel, -self.init_rel], dim=0)
why cat them when use ‘transe’?
cheers
Thanks for your open code. I want to know that how much time for one epoch(like compGCN-ConvE)?
Hello, I want to quote your article, which needs to be reproduced now. Please tell me about the best superparameters of WN18RR, thank you very much.
Hello. This is just a personal suggestion that I had rather than an issue with the code itself.
I think that it may be helpful for future users if you specified in the README
that users should first create ./log/
, ./data/
, and ./checkpoints/
files before running the code. It's not a big deal, but it would be a bit better user experience IMO.
Thanks.
Hi,
Thanks for this amazing work! May I have your code for entity classification task?
Hello. I'm just curious if 1.1.2 is the correct version for the torch-scatter
you're using. I'm asking because I notice that you have a from torch_scatter import scatter
statement in your message_passing.py
module, and as far as I'm aware the scatter
wrapper was not introduced until version 2.0+.
I've tried downloading version 1.1.2 and running your code, but I'm getting a
ImportError: cannot import name 'broadcast' from `torch_scatter.utils` (/home/user/anaconda3/envs/userconda/lib/python3.7/site-packages/torch_scatter/utils/__init__.py)
I normally don't like opening Git Issues with these kind of problems, but I was hoping perhaps someone would be kind enough to shed some light on my predicament. Thanks!
Hi,
In appendix A, I saw that you calculated the mrr by each relation category. However, when I am trying to reproduce the number, it's weird that I get the number for 1-n and n-1 swapped. For example, for compgcn + conve, for the mrr of 1-N relations, I got number 0.25, but in your paper you reported (0.112+0.779)/2 = 0.4455.
I wonder if (1) if I calculated it in a wrong way (2) you can provide the script of how you calculated these numbers
Hello,
Thanks for the great work. I am taking your work as my baseline.
I notice that you have a parameter called gamma, which is "margin" in your description.
As I understand, you did not include learning rate decay in your code. In the function "fit" of "run.py", what you did is just to stop training after continuous 25 epochs without improving MRR. So what exactly does this "margin" mean here?
Best Regards,
Zifeng
According to the model in distmult
paper,
Hi, thanks for such a good job first!
I'm reproducing the model results and notice that the performance on head data (i.e. use tail and inverse relation to predict head) is extremely worse than tail data, whose MRR are 0.2+ and 0.4+ separately. I've tried two configurations, one is using transe for opn
and score_func
, the other is distmul for opn
and score_func
, and both exist the above performance gap. Do you have any idea how this phenomenon occur?
Best wishes.
In the function run_epoch
, you calculate the loss between pred
and label
. For my understanding, pred
are the scores for all entities (or objects) given subjects and relations; however, label
is not relevant to objects. Could you please explain what is the label
?
Thanks for your amazing work! And I'm also very interested in the graph classification in your work. May I have your code for graph classification task?
Hi, nice work. How do I get the trained embeddings of entities and relations?
In your requirement.txt file, torch==1.4.0, torch_scatter==2.0.4.
I have installed the version as you said, but it goes wrong:
RuntimeError: Detected that PyTorch and torch_scatter were compiled with different CUDA versions. PyTorch has CUDA version 10.1 and torch_scatter has CUDA version 10.2. Please reinstall the torch_scatter that matches your PyTorch install.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.