GithubHelp home page GithubHelp logo

malllabiisc / compgcn Goto Github PK

View Code? Open in Web Editor NEW
591.0 18.0 106.0 4.45 MB

ICLR 2020: Composition-Based Multi-Relational Graph Convolutional Networks

License: Apache License 2.0

Python 99.65% Shell 0.35%
link-prediction relation-embeddings iclr2020 graph-convolutional-networks deep-learning pytorch graph-representation-learning

compgcn's People

Contributors

soumyasanyal avatar svjan5 avatar tkukurin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

compgcn's Issues

Which evaluation protocol do you use

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!

efficiency about batch training

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!

About why you pre-calculate all node representations

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?

What about the lowest GPU needed?

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.

Who can reproduce the reported results on the dataset WN18RR?

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?

Data leakage?

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?

ValueError: Unable to configure handler 'file_handler'

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'

The code that caused this error is in:run.py->line 451
1655005316151

The scripts to reproduce the results.

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

Why do you use outgoing edges as neighbor?

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.

Run with relation basis vectors

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?

Regarding number of GCN updates

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.

CompGCN with TransE decoder does not converge

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?

Random adjacency matrices do not affect the performance

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?

Small details in Transe

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

Model efficiency

Thanks for your open code. I want to know that how much time for one epoch(like compGCN-ConvE)?

Just a small suggestion.

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.

Problem for running

I'm so sorry to bother you. I have problems when run run.py——helper.py——logging.config.dictConfig(config_dict),How could I solve this problem?

image

Is 1.1.2 the correct version for `torch-scatter`?

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!

How do you calculate mrr by relation category

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

What does gamma (margin) mean in your hyper parameter?

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

3 questions or suggestions

  1. run.py: error: unrecognized arguments: -init_embed 200
    After using "python run.py -score_func transe -opn sub -gamma 9 -hid_drop 0.1 -init_embed 200 " this sentence in terminal, I find that it occurred an error for me said "python run.py -score_func transe -opn sub -gamma 9 -hid_drop 0.1 -init_embed 200 ".
    I find that in "run.py" there isn't any "init_embed" code. Is that in fact a "-embed_dim" attribute or other attribute?
  2. I'm on Windows, so I have to change "'%H:%M:%S'" to "'%H_%M_%S' or so on. Coz Windows can't support ":" in the name of files.
  3. Honestly it's the first time for me to run a deep learning model... And it said my virtual memory is not enough(OSError: [WinError 1455]). I don't know how to deal with it. Maybe I have to buy a new computer?
    So I wonder how much memory do I finally need?

confused about distmult

According to the model in distmult paper, $$score = h_s * M_r * h_o^T$$. However, in the most papers about knowledge graph completion including the model in CompGCN, they are realized as a form of $$score = h_s * r * h_o^T$$. May I ask you about the insight behind your realization form?

Why performance on head data hugely worse than tail data?

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.

What is the label in run_epoch

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?

Code for graph classification task

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?

About cuda version

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.

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.