Code and Data for the paper: "Disentangled Ontology Embedding for Zero-shot Learning". In this work, we focus on ontologies for augmenting ZSL, and propose to learn disentangled ontology embeddings to capture and utilize more fine-grained class relationships in different aspects. We also contribute a new ZSL framework named DOZSL, which contains two new ZSL solutions based on generative models and graph propagation models respectively, for effectively utilizing the disentangled ontology embeddings for zero-shot image classification (ZS-IMGC) and zero-shot KG completion (ZS-KGC) with unseen relations.
python 3.5
PyTorch >= 1.5.0
Download public pre-trained image features and dataset split for AwA2, uncompress it and put the files in AWA2 folder to our folder ZS_IMGC/data/AwA2/
.
Download pre-trained image features of ImageNet classes and their class splits from here and put them to the folder ZS_IMGC/data/ImageNet/
.
Download from here and put them to the corresponding data folder.
The first thing you need to do is to train the disentangled ontology encoder, using the codes in the folders OntoEncoder/DOZSL_RD
(for RD variants) and OntoEncoder/DOZSL_AGG
(for AGG variants).
Steps:
- Running
run.py
in each method folder to obtain the disentangled concept embeddings; - Selecting target class or relation embeddings from the trained concept embeddings by running
python out_imgc.py
for ZS-IMGC task andpython out_kgc.py
for ZS-KGC task.
With the selected class embedding or relation embedding, you can take it to perform downstream ZSL tasks using the generative model or graph propagation model.
The codes for generative model are in folder ZS_IMGC/models/DOZSL_GAN
and ZS_KGC/models/DOZSL_GAN
for ZS-IMGC and ZS-KGC tasks, respectively,
for propagation model are in folder ZS_IMGC/models/DOZSL_GCN
and ZS_KGC/models/DOZSL_GCN
.
Note: you can skip the step of training ontology encoder if you just want to use the ontology embedding we learned, the embedding files have already been attached in the corresponding directories.
- The baselines for different ZSL methods are in the folders
ZS_IMGC/models
andZS_KGC/models
for ZS-IMGC and ZS-KGC tasks, respectively. - The baselines for different ontology embedding methods are in the folder
OntoEncoder
.