Giter Club home page Giter Club logo

alinet's Introduction

Graph neural networks (GNNs) have emerged as a powerful paradigm for embedding-based entity alignment due to their capability of identifying isomorphic subgraphs. However, in real knowledge graphs (KGs), the counterpart entities usually have non-isomorphic neighborhood structures, which easily causes GNNs to yield different representations for them. To tackle this problem, we propose a new KG alignment network, namely AliNet, aiming at mitigating the non-isomorphism of neighborhood structures in an end-to-end manner. As the direct neighbors of counterpart entities are usually dissimilar due to the schema heterogeneity, AliNet introduces distant neighbors to expand the overlap between their neighborhood structures. It employs an attention mechanism to highlight helpful distant neighbors and reduce noises. Then, it controls the aggregation of both direct and distant neighborhood information using a gating mechanism. We further propose a relation loss to refine entity representations. We perform thorough experiments with detailed ablation studies and analyses on five entity alignment datasets, demonstrating the effectiveness of AliNet.

Dataset

We use two entity alignment datasets DBP15K and DWY100K in our experiments. DBP15K can be downloaded from JAPE and DWY100K is from BootEA.

Code

  • "alinet.py" is the implementation of AliNet (with relation loss and iterative neighborhood augmentation).

Dependencies

  • Python 3
  • Tensorflow 2.0 (Important!!!)
  • Scipy
  • Numpy
  • Pandas
  • Scikit-learn

Running

For example, to run AliNet on DBP15K ZH-EN, use the following script (supposed that the DBK15K dataset has been downloaded into the folder '../data/'):

python3 main.py --input ../data/DBP15K/zh_en/mtranse/0_3/

To run AliNet on DBP15K, use the following script:

bash run_dbp15k.sh

To run AliNet (w/o iterative neighborhood augmentation) on DBP15K ZH-EN, use the following script:

python3 main.py --input ../data/DBP15K/zh_en/mtranse/0_3/ --sim_th 0.0

To run AliNet (w/o relation loss and neighborhood augmentation) on DBP15K ZH-EN, use the following script:

python3 main.py --input ../data/DBP15K/zh_en/mtranse/0_3/ --rel_param 0.0 --sim_th 0.0

If you have any difficulty or question in running code and reproducing experimental results, please email to [email protected] or [email protected].

Citation

If you use our model or code, please kindly cite it as follows:

@inproceedings{AliNet,
  author    = {Zequn Sun,
               Chengming Wang, 
               Wei Hu, 
               Muhao Chen, 
               Jian Dai, 
               Wei Zhang, 
               Yuzhong Qu},
  title     = {Knowledge Graph Alignment Network with Gated Multi-Hop Neighborhood Aggregation},
  booktitle = {AAAI},
  pages     = {222--229},
  year      = {2020}
}

alinet's People

Contributors

sunzequn 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

Watchers

 avatar  avatar  avatar  avatar  avatar

alinet's Issues

AttributeError: 'Tensor' object has no attribute 'numpy'

Hi,

When I run the code, an error occurred as below. The TensorFlow version is 2.3.1, and memory is 60 GBs. As the work does not use GPUs, I think the failure of loading a GPU library may not be related.

Could you help me check it (error occurs at line 304 of ``alinet.py'')?
Cheers,

Getting AliNet model...
2020-10-05 13:03:26.566125: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1
2020-10-05 13:03:26.644590: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:3b:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.645612: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 1 with properties:
pciBusID: 0000:af:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.648167: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 2 with properties:
pciBusID: 0000:d8:00.0 name: GeForce RTX 2080 Ti computeCapability: 7.5
coreClock: 1.545GHz coreCount: 68 deviceMemorySize: 10.73GiB deviceMemoryBandwidth: 573.69GiB/s
2020-10-05 13:03:26.648240: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1
2020-10-05 13:03:26.650992: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10
2020-10-05 13:03:26.652471: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10
2020-10-05 13:03:26.652902: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10
2020-10-05 13:03:26.654970: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10
2020-10-05 13:03:26.656429: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10
2020-10-05 13:03:26.656771: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudnn.so.7'; dlerror: libcudnn.so.7: cannot open shared object file: No such file or directory
2020-10-05 13:03:26.656838: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1753] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
2020-10-05 13:03:26.657666: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-05 13:03:26.707577: I tensorflow/core/platform/profile_utils/cpu_utils.cc:104] CPU Frequency: 3400000000 Hz
2020-10-05 13:03:26.721101: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5611a002ffd0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-05 13:03:26.721315: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-10-05 13:03:26.724715: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-05 13:03:26.724866: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263]
Traceback (most recent call last):
File "/home/uqyliu42/workspace/pycharm/AliNet/code/main.py", line 60, in
gcn_model.train(args.batch_size, max_epochs=args.max_epoch, start_valid=args.start_valid, eval_freq=args.eval_freq)
File "/home/uqyliu42/workspace/pycharm/AliNet/code/alinet.py", line 304, in train
grads = tape.gradient(batch_loss, self.model.trainable_variables)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/backprop.py", line 1073, in gradient
unconnected_gradients=unconnected_gradients)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/imperative_grad.py", line 77, in imperative_grad
compat.as_str(unconnected_gradients.value))
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/eager/backprop.py", line 162, in _gradient_function
return grad_fn(mock_op, *out_grads)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py", line 212, in _SumGrad
op.inputs[1])
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py", line 3904, in reduced_shape
input_shape = input_shape.numpy()
AttributeError: 'Tensor' object has no attribute 'numpy'

Implementation of loss function

Hi thanks for the great work.

I'm just reading the code and wondering where is the implementation of the L loss (equation 11 in the paper)?

Cheers,
Yu

Input 0 is incompatible with layer model

Thanks for your work!
I met this problem:
Traceback (most recent call last):
File "main.py", line 58, in
gcn_model.train(args.batch_size, max_epochs=args.max_epoch, start_valid=args.start_valid, eval_freq=args.eval_freq)
File "/hy-tmp/AliNet/code/alinet.py", line 344, in train
self.input_embeds, self.output_embeds_list = self.model((self.pos_link_batch, self.neg_link_batch),
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 998, in call
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
File "/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/input_spec.py", line 271, in assert_input_compatibility
raise ValueError('Input ' + str(input_index) +
ValueError: Input 0 is incompatible with layer model: expected shape=(None, 2), found shape=(4500, 3)

What should I do?

Errors when save model

Hi, I just save the model with the following line, gcn_model.model.save("./test_model") in the main.py, however, an error occurs as below:

File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py", line 219, in _variable_v1_call
shape=shape)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow_core/python/ops/variables.py", line 65, in getter
return captured_getter(captured_previous, **kwargs)
File "/home/uqyliu42/miniconda3/envs/tf20/lib/python3.7/site-packages/tensorflow_core/python/eager/def_function.py", line 502, in invalid_creator_scope
"tf.function-decorated function tried to create "
ValueError: tf.function-decorated function tried to create variables on non-first call.

I searched and didn't find a solution. Do you have any idea why this error happen?

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.