Skip to content

Commit

Permalink
fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
varisd committed Feb 6, 2019
1 parent fbad9af commit 1c16164
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion neuralmonkey/decoders/autoregressive.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def embedding_size(self) -> int:
"size of the reused embeddings from the "
"`embeddings_source`.")

return self.embeddings_source.dimension
return self.embeddings_source.embedding_matrix.get_shape()[1].value

@tensor
def go_symbols(self) -> tf.Tensor:
Expand Down
15 changes: 8 additions & 7 deletions neuralmonkey/decoders/sequence_labeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self,
name: str,
encoder: TemporalStateful,
data_id: str,
vocabulary: Vocabulary,
vocabulary: Vocabulary = None,
embeddings_source: EmbeddedSequence = None,
dropout_keep_prob: float = 1.0,
reuse: ModelPart = None,
Expand All @@ -34,19 +34,20 @@ def __init__(self,
ModelPart.__init__(self, name, reuse, save_checkpoint, load_checkpoint,
initializers)

self.vocabulary = vocabulary
self.embeddings_source = embeddings_source
self.encoder = encoder
self.data_id = data_id
self.dropout_keep_prob = dropout_keep_prob

# We provide only embedding_source when we want to input and output
# We provide only embedding_source when we want to tie input and output
# projections
if self.embeddings_source is not None and self.vocabulary is not None:
warn("Both `vocabulary` and `embedding_source` was provided. "
"using `embedding_source.vocabulary` instead of provided "
"`vocabulary`")
if (self.embeddings_source is None) == (vocabulary is None):
raise ValueError("You must specify either `vocabulary or` or "
"`embeddings_source`, not both")
elif self.embeddings_source is not None:
self.vocabulary = self.embeddings_source.vocabulary
elif vocabulary is not None:
self.vocabulary = vocabulary
# pylint: enable=too-many-arguments

@property
Expand Down
2 changes: 1 addition & 1 deletion neuralmonkey/readers/string_vector_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def process_line(line: str, lineno: int, path: str) -> np.ndarray:

return np.array(numbers, dtype=dtype)

def reader(files: List[str])-> Iterable[List[np.ndarray]]:
def reader(files: List[str]) -> Iterable[List[np.ndarray]]:
for path in files:
current_line = 0

Expand Down
1 change: 0 additions & 1 deletion tests/bert.ini
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ dropout_keep_prob=0.9
class=decoders.sequence_labeler.SequenceLabeler
name="labeler_bert"
encoder=<encoder>
vocabulary=<vocabulary>
data_id="source_masked"
dropout_keep_prob=0.5
embeddings_source=<sequence>
Expand Down

0 comments on commit 1c16164

Please sign in to comment.