Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes #2

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This code implements the state-of-the-art Knowledge Graph Embedding [algorithms]
* An example configuration file (complex.json) can be found in the repository.
### Specifications
* "batch_size": Train Batch Size,
* "entity_dim": Embedding Dimension (must be specified),
* "ent_dim": Embedding Dimension (must be specified),
* "exp_name": Experiment Name,
* "is_dev": True if you want to test on validation data (must be specified),
* "is_typed": True if you want to use Type Regularizer (default False),
Expand Down
2 changes: 1 addition & 1 deletion constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@

fb13_ents=75043
fb13_rels=13
cat_file='/home/mitarb/kotnis/Code/kge-rl/entity_cat.cpkl'
cat_file='./entity_cat.cpkl'
2 changes: 1 addition & 1 deletion experiment_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def train(config,exp_name,data_path,resume=False,tune=False):
state = None
if resume or tune:
params_path = os.path.join(results_dir, '{}_params.pt'.format(config['model']))
model.load_state_dict(torch.load(params_path))
model.load_state_dict(torch.load(params_path, map_location='cpu'))
if resume:
state_path = os.path.join(results_dir,'{}_optim_state.pt'.format(config['model']))
state = torch.load(state_path)
Expand Down
8 changes: 4 additions & 4 deletions negative_sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ class Typed_Sampler(Static_Sampler):
def __init__(self,triples,num_samples,results_dir,filtered=True):
super(Typed_Sampler, self).__init__(triples,num_samples,filtered)
print("\tNeg. Sampler: Typed, num_samples: {}, filtered: {}".format(num_samples, filtered))
self.ent_index = pickle.load(open(os.path.join(results_dir, constants.entity_ind)))
self.ent_index = pickle.load(open(os.path.join(results_dir, constants.entity_ind), 'rb'))
self.ent_cats,self.cat_ents = self.load_cats()


def load_cats(self):
ent_cats, cat_ents = dict(),dict()
all_cats = pickle.load(open(constants.cat_file))
all_cats = pickle.load(open(constants.cat_file, 'rb'))
for k,v in all_cats.iteritems():
ent_cats[self.ent_index[k]] = v
for c in v:
Expand Down Expand Up @@ -244,9 +244,9 @@ def get_entity(self,ex,is_target):
def load_rescal(self):
from models import Rescal
import torch
path = "/home/mitarb/kotnis/Data/neg_sampling/wordnet/corrupt/rescal/rescal_100/rescal_params.pt"
path = "/home/sch/schoenitzer/nsp/kge-rl/data/FB15k/rescal-random-100/rescal_params.pt"
model = Rescal(constants.fb15k_ents,constants.fb15k_rels,100)
state_dict = torch.load(path)
state_dict = torch.load(path, map_location='cpu')
model.load_state_dict(state_dict)
model.eval()
return model
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
from Cython.Build import cythonize

setup(
ext_modules = cythonize("/home/kotnis/code/kge-rl/sample_list.pyx")
ext_modules = cythonize("./sample_list.pyx")
)