Git Product home page Git Product logo

zero-shot-knowledge-graph-relational-learning's People

Contributors

panda0406 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

Watchers

 avatar  avatar  avatar

zero-shot-knowledge-graph-relational-learning's Issues

Losing Complex Embedding real or imaginary part

Hi, Pengda. Thanks for sharing the code.
After downloading the given dataset, I found that the Complex embedding matrix in the directory Embed_used misses real or imaginary part. More details are shown below.
ComplEx.npz only has a matrix with the shape (69127, 100).
Both TransE.npz and DistMult.npz have embedding matrix with the shape (65567, 100).
According the implementation details, ComplEx should be (69127, 200).

Where are the relationships in the neighbor_encoder

Hi, Pengda. I am very very interested in your work, it's really a good job!
I tried to run your code recently, but I didn't find the relationship in the neighbor_encoder function that was there, is somewhere else? Here is the code for the feature extractor in Network.py
Sincerely hope for your reply.

class Extractor(nn.Module):
"""
Matching metric based on KB Embeddings
"""
def init(self, embed_dim, num_symbols, embed=None):
super(Extractor, self).init()
self.embed_dim = int(embed_dim)
self.pad_idx = num_symbols
self.symbol_emb = nn.Embedding(num_symbols + 1, embed_dim, padding_idx=num_symbols)
self.num_symbols = num_symbols

    self.gcn_w = nn.Linear(self.embed_dim, int(self.embed_dim/2))
    self.gcn_b = nn.Parameter(torch.FloatTensor(self.embed_dim))

    self.fc1 = nn.Linear(self.embed_dim, int(self.embed_dim/2))
    self.fc2 = nn.Linear(self.embed_dim, int(self.embed_dim/2))

    self.dropout = nn.Dropout(0.2)
    self.dropout_e = nn.Dropout(0.2)

    self.symbol_emb.weight.data.copy_(torch.from_numpy(embed))

    self.symbol_emb.weight.requires_grad = False

    d_model = self.embed_dim * 2
    self.support_encoder = SupportEncoder(d_model, 2*d_model, dropout=0.2)
    #self.query_encoder = QueryEncoder(d_model, process_steps)

def neighbor_encoder(self, connections, num_neighbors):
    '''
    connections: (batch, 200, 2)
    num_neighbors: (batch,)
    '''
    num_neighbors = num_neighbors.unsqueeze(1)
    entities = connections[:,:,1].squeeze(-1)
    ent_embeds = self.dropout(self.symbol_emb(entities)) # (batch, 50, embed_dim)
    concat_embeds = ent_embeds

    out = self.gcn_w(concat_embeds)
    out = torch.sum(out, dim=1) # (batch, embed_dim)
    out = out / num_neighbors
    return out.tanh()

def entity_encoder(self, entity1, entity2):
    entity1 = self.dropout_e(entity1)
    entity2 = self.dropout_e(entity2)
    entity1 = self.fc1(entity1)
    entity2 = self.fc2(entity2)
    entity = torch.cat((entity1, entity2), dim=-1)
    return entity.tanh() # (batch, embed_dim)


def forward(self, query, support, query_meta=None, support_meta=None):
    '''
    query: (batch_size, 2)
    support: (few, 2)
    return: (batch_size, )
    '''
    query_left_connections, query_left_degrees, query_right_connections, query_right_degrees = query_meta
    support_left_connections, support_left_degrees, support_right_connections, support_right_degrees = support_meta

    query_e1 = self.symbol_emb(query[:,0]) # (batch, embed_dim)
    query_e2 = self.symbol_emb(query[:,1]) # (batch, embed_dim)
    query_e = self.entity_encoder(query_e1, query_e2)

    support_e1 = self.symbol_emb(support[:,0]) # (batch, embed_dim)
    support_e2 = self.symbol_emb(support[:,1]) # (batch, embed_dim)
    support_e = self.entity_encoder(support_e1, support_e2)

    query_left = self.neighbor_encoder(query_left_connections, query_left_degrees)
    query_right = self.neighbor_encoder(query_right_connections, query_right_degrees)

    support_left = self.neighbor_encoder(support_left_connections, support_left_degrees)
    support_right = self.neighbor_encoder(support_right_connections, support_right_degrees)
    
    query_neighbor = torch.cat((query_left, query_e,  query_right), dim=-1) # tanh
    support_neighbor = torch.cat((support_left, support_e, support_right), dim=-1) # tanh

    support = support_neighbor
    query = query_neighbor

    support_g = self.support_encoder(support) # 1 * 100
    query_g = self.support_encoder(query)

    support_g = torch.mean(support_g, dim=0, keepdim=True)

    # cosine similarity
    matching_scores = torch.matmul(query_g, support_g.t()).squeeze()

    return query_g, matching_scores

Could you tell me your GPU memory size?

Hey, I encountered some problems in the process of reproducing your paper experiments. It‘s warning "Out of Memory“ when I use the NELL dataset to running such loop ”for relname in self.train_tasks.keys():" in file "trainer. py". So I want to understand the GPUs use in your experiments. Please, It's important for me.

Wiki's Data

Hi, Pengda, thanks a lot for sharing the wonderful code. Hope to see the Wiki's corresponding code sooner.

Issue about code on Wiki dataset

Hi, Pengda. I am very very interested in your work, it's really a good job!
I tried to run your code recently, but I found it can't work well on Wiki-ZS dataset. I guess it may because the selection of extractor pretrain times. You have provided the pretrain times for NELL (16000), but I think 16000 may not be the best choice for Wiki. Could you provide your pretrain times for Wiki?
Sincerely hope for your reply.

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.