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

(WIP) Triple classification #106

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open

Conversation

samuelbroscheit
Copy link
Member

I didn't want this PR go to waste so I fixed it up to its current state. It works now except for the following, that would have to be adressed:

There is an incomplete attempt from me to integrate the TC datasets (where valid and test have a label) WN11 and FB13 into our dataset framework. The question here is, how we want to proceed here. My plan was to hae a load_labels() function similar to load triples().

atschalz and others added 19 commits June 4, 2020 15:36
…sec on fb15k, implemented an alternative way to find the thresholds, different slight changes
…which were not used in other implementations, include unique condition while sampling negatives from list to ensure same probability, Change find_thresholds so that the smallest score which gives the highest accuracy is used as threshold
…sholds, added comments for triple classification specification in default file, Included specification of evaluating on either test or valid data depending on the task (Test or validation during train)
…e_metrics, updated comment documentation, easier way to retrieve labels per relations in generate function, minor simplifications and error fixings
@rgemulla rgemulla force-pushed the triple_classification branch from 34ec99c to 8a4416f Compare June 5, 2020 11:41
@@ -11,8 +11,11 @@ lookup_embedder.dim: 100
lookup_embedder.initialize: xavier_uniform_
eval:
type: triple_classification
metrics_per.relation: False
triple_classification_random_seed: False
triple_classification.random_seed: False
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

triple_classification.random_seed is not used anymore

@@ -423,6 +423,14 @@ valid:

## EVALUATION ##################################################################

triple_classification:
random_seed: False
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: random_seed can be removed

@@ -31,6 +36,7 @@ def __init__(self, config: Config, configuration_key: str, dataset: Dataset):

def _prepare(self,):
train_data = self.dataset.split("train")
#TODO probably outdated as it refers to out-commented code
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct

@@ -20,7 +20,12 @@ def __init__(self, config: Config, configuration_key: str, dataset: Dataset):
self.o_entities = None
uni_sampler_config = config.clone()
# uni_sampler_config.set("negative_sampling.num_samples.s", self.get_option("num_samples.s"))
# TODO this is redundant as uniform.sample() is called with "num_samples" here in self.sample()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes that is correct

Comment on lines +25 to +28
# TODO maybe changing the API of KGEsampler.sample() to also accept a param "filter"
# as it is the case already with "num_samples"
# then we would not rely here on configuration options which actually
# belong to a training job
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Absolutely. Currently the negative sampling config is mixing the Job and the Sampler. This should be split up in a separate PR.

@@ -121,7 +141,8 @@ def _prepare(self):

self.config.log("Generate data with corrupted and true triples...")

if self.eval_split == "test":
# TODO maybe should be generalized to allow for other splits as valid_wo_unseen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I agree, see my comment #115 (comment)


positives_test = self.dataset.split("test")
negatives_test = self.dataset.split("test_negatives")
self.tune_data = torch.cat((positives_test, negatives_test)).to(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval_data

negatives_test = self.dataset.split("test_negatives")
self.tune_data = torch.cat((positives_test, negatives_test)).to(
self.device)
self.tune_labels = torch.cat(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eval_labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants