Skip to content

Commit

Permalink
Bump 3.0.3 (#2277)
Browse files Browse the repository at this point in the history
* various fixes along v3.0.3
  • Loading branch information
vince62s authored Dec 19, 2022
1 parent 3b7c92b commit 5f32750
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@


## [Unreleased]
## [3.0.3](https://github.com/OpenNMT/OpenNMT-py/tree/3.0.3) (2022-12-16)
* fix loss normalization when using accum or nb GPU > 1
* use native CrossEntropyLoss with Label Smoothing. reported loss/ppl impacted by LS
* fix long-time coverage loss bug thanks Sanghyuk-Choi
* fix detok at scoring / fix tokenization Subword_nmt + Sentencepiece
* various small bugs fixed

## [3.0.2](https://github.com/OpenNMT/OpenNMT-py/tree/3.0.2) (2022-12-07)
* pyonmttok.Vocab is now pickable. dataloader switched to spawn. (MacOS/Windows compatible)
Expand Down
2 changes: 1 addition & 1 deletion onmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
__all__ = [onmt.inputters, onmt.encoders, onmt.decoders, onmt.models,
onmt.utils, onmt.modules, "Trainer"]

__version__ = "3.0.2"
__version__ = "3.0.3"
3 changes: 2 additions & 1 deletion onmt/encoders/rnn_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def forward(self, src, src_len=None):
if src_len is not None and not self.no_pack_padded_seq:
# src lengths data is wrapped inside a Tensor.
src_len_list = src_len.view(-1).tolist()
packed_emb = pack(emb, src_len_list, batch_first=True)
packed_emb = pack(emb, src_len_list, batch_first=True,
enforce_sorted=False)

enc_out, enc_final_hs = self.rnn(packed_emb)

Expand Down
2 changes: 1 addition & 1 deletion onmt/inputters/text_corpus.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def save_transformed_sample(opts, transforms, n_sample=3):
open(dest_base + ".tgt", 'w', encoding="utf-8") as f_tgt:
for i, item in enumerate(c_iter):
maybe_example = process(CorpusTask.TRAIN, [item])
if len(maybe_example) > 0:
if maybe_example is not None:
maybe_example = maybe_example[0]
src_line, tgt_line = (maybe_example['src']['src'],
maybe_example['tgt']['tgt'])
Expand Down
2 changes: 1 addition & 1 deletion onmt/inputters/text_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def text_sort_key(ex):
"""Sort using the number of tokens in the sequence."""
if ex['tgt']:
return len(ex['src']['src_ids']), len(ex['tgt']['tgt_ids'])
return max(len(ex['src']['src_ids']), len(ex['tgt']['tgt_ids']))
return len(ex['src']['src_ids'])


Expand Down
2 changes: 1 addition & 1 deletion onmt/utils/optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def build_torch_optimizer(model, opt):
params,
lr=opt.learning_rate,
betas=betas,
eps=1e-9)
eps=1e-8)
elif opt.optim == 'sparseadam':
dense = []
sparse = []
Expand Down
4 changes: 1 addition & 3 deletions onmt/utils/scoring_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ def translate(self, model, transformed_batches, gpu_rank, step, mode):
_, preds_ = translator._translate(
infer_iter, transform=self.transform)
preds += preds_
with open("x", "a") as f:
f.write(str(len(preds_)))

# detokenize refs
# apply_reverse refs
if self.transforms:
texts_ref = [self.transform.apply_reverse(raw_ref)
for raw_ref in raw_refs]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
description='A python implementation of OpenNMT',
long_description=long_description,
long_description_content_type='text/markdown',
version='3.0.2',
version='3.0.3',
packages=find_packages(),
project_urls={
"Documentation": "http://opennmt.net/OpenNMT-py/",
Expand Down

0 comments on commit 5f32750

Please sign in to comment.