Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

(Rebased) Add ELMo to BCN #1308

Merged
merged 7 commits into from
May 30, 2018
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix paths
  • Loading branch information
nelson-liu committed May 30, 2018
commit 8ea161ca256c78928340299d9ae9402be341d385
14 changes: 7 additions & 7 deletions allennlp/tests/models/biattentive_classification_network_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def test_feedforward_bcn_can_train_save_and_load(self):

def test_input_and_output_elmo_bcn_can_train_save_and_load(self):
# pylint: disable=line-too-long
self.ensure_model_can_train_save_and_load('tests/fixtures/biattentive_classification_network/elmo_experiment.json')
self.ensure_model_can_train_save_and_load(self.FIXTURES_ROOT / 'biattentive_classification_network' / 'elmo_experiment.json')

def test_output_only_elmo_bcn_can_train_save_and_load(self):
# pylint: disable=line-too-long
self.ensure_model_can_train_save_and_load('tests/fixtures/biattentive_classification_network/output_only_elmo_experiment.json')
self.ensure_model_can_train_save_and_load(self.FIXTURES_ROOT / 'biattentive_classification_network' / 'output_only_elmo_experiment.json')

def test_batch_predictions_are_consistent(self):
self.ensure_batch_predictions_are_consistent()
Expand Down Expand Up @@ -66,15 +66,15 @@ def test_no_elmo_but_set_flags_throws_configuration_error(self):
Model.from_params(self.vocab, tmp_params.get("model"))

def test_elmo_but_no_set_flags_throws_configuration_error(self):
params = Params.from_file('tests/fixtures/biattentive_classification_network/elmo_experiment.json')
params = Params.from_file(self.FIXTURES_ROOT / 'biattentive_classification_network' / 'elmo_experiment.json')
# Elmo is specified in the model, but set both flags to false.
params["model"]["use_input_elmo"] = False
params["model"]["use_integrator_output_elmo"] = False
with pytest.raises(ConfigurationError):
Model.from_params(self.vocab, params.get("model"))

def test_elmo_num_representation_set_flags_mismatch_throws_configuration_error(self):
params = Params.from_file('tests/fixtures/biattentive_classification_network/elmo_experiment.json')
def test_elmo_num_repr_set_flags_mismatch_throws_configuration_error(self):
params = Params.from_file(self.FIXTURES_ROOT / 'biattentive_classification_network' / 'elmo_experiment.json')
# Elmo is specified in the model, with num_output_representations=2. Set
# only one flag to true.
tmp_params = deepcopy(params)
Expand All @@ -100,10 +100,10 @@ def test_no_elmo_tokenizer_throws_configuration_error(self):
with pytest.raises(ConfigurationError):
# pylint: disable=line-too-long
self.ensure_model_can_train_save_and_load(
'tests/fixtures/biattentive_classification_network/broken_experiments/no_elmo_tokenizer_for_elmo.json')
self.FIXTURES_ROOT / 'biattentive_classification_network' / 'broken_experiments' / 'no_elmo_tokenizer_for_elmo.json')

def test_elmo_in_text_field_embedder_throws_configuration_error(self):
with pytest.raises(ConfigurationError):
# pylint: disable=line-too-long
self.ensure_model_can_train_save_and_load(
'tests/fixtures/biattentive_classification_network/broken_experiments/elmo_in_text_field_embedder.json')
self.FIXTURES_ROOT / 'biattentive_classification_network' / 'broken_experiments' / 'elmo_in_text_field_embedder.json')