Skip to content

Commit

Permalink
bugfix: added cast; plus fixed stupid mistakes in test cases (#426)
Browse files Browse the repository at this point in the history
* bugfix: added cast; plus fixed stupid mistakes in test cases that let it sneak in
  • Loading branch information
mjpost authored and fhieber committed Jun 1, 2018
1 parent fc440df commit 30a58fe
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ Note that Sockeye has checks in place to not translate with an old model that wa

Each version section may have have subsections for: _Added_, _Changed_, _Removed_, _Deprecated_, and _Fixed_.

## [1.18.21]
### Fixed
- Constrained decoding was missed a crucial cast
- Fixed test cases that should have caught this

## [1.18.20]
### Changed
- Transformer parametrization flags (model size, # of attention heads, feed-forward layer size) can now optionally
defined separately for encoder & decoder. For example, to use a different transformer model size for the encoder,
pass `--transformer-model-size 1024:512`.
pass `--transformer-model-size 1024:512`.

## [1.18.19]
### Added
Expand Down
2 changes: 1 addition & 1 deletion sockeye/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.

__version__ = '1.18.20'
__version__ = '1.18.21'
2 changes: 1 addition & 1 deletion sockeye/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ def _get_best_from_beam(self,
unmet = mx.nd.array([c.num_needed() if c is not None else 0 for c in constraints], ctx=self.context)
filtered = mx.nd.where(unmet == 0, seq_scores, self.inf_array)
filtered = filtered.reshape((self.batch_size, self.beam_size))
best_ids += mx.nd.argmin(filtered, axis=1)
best_ids += mx.nd.cast(mx.nd.argmin(filtered, axis=1), dtype='int32')

histories = beam_histories if beam_histories is not None else [None] * self.batch_size # type: List
return [self._assemble_translation(*x) for x in zip(sequences[best_ids],
Expand Down
2 changes: 1 addition & 1 deletion test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def tmp_digits_dataset(prefix: str,
end_pos = min(target_len, 3)
constraint = ' '.join(target_words[start_pos:end_pos])
new_source['constraints'] = [constraint]
new_sources.append(json.dumps(new_source))
new_sources.append(json.dumps(new_source))

with open(data['test_source'], 'w') as out:
for json_line in new_sources:
Expand Down
2 changes: 1 addition & 1 deletion test/integration/test_seq_copy_int.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def test_seq_copy(train_params: str,
train_target_path=data['target'],
dev_source_path=data['validation_source'],
dev_target_path=data['validation_target'],
test_source_path=data['test_target'],
test_source_path=data['test_source'],
test_target_path=data['test_target'],
train_source_factor_paths=train_source_factor_paths,
dev_source_factor_paths=dev_source_factor_paths,
Expand Down

0 comments on commit 30a58fe

Please sign in to comment.