Comments (1)
@JulianSlzr , in the current nmt scripts, the token loss is averaged by the total number of the tokens in the mini-batch. You can imagine it by concatenating all the sequences in the mini-batch to a single one and taking average. You can find it in the following code.
loss = loss * (tgt_seq.shape[1] - 1) / (tgt_valid_length - 1).mean()
This ensures that all the tokens are equally weighted. In fact, we are minimizing the following objective:
\sum_{i=1}^N\sum_{t=1}^{T_i}\logP(y_t^i|y_1^i, ...y_{t-1}^i, X^i, \Theta)
But sure, what you propose can be useful in some scenarios. A PR is always welcome.
from gluon-nlp.
Related Issues (20)
- Upgrade sacremoses to 0.0.44
- Loading 'distilbert_6_768_12' is broken HOT 2
- Operator npx.broadcast_like HOT 3
- [v0.x] Some CPU tests fail after switching to use MXNet 1.8.0 HOT 1
- Dead link to build_steps.groovy in contribute.rst#make-changes
- difference between gluonnlp 0.10.0 and gluonnlp 1.0.0 RoBERTaModel?
- Badge link was broken in README
- GPT2 tests mysteriously killed HOT 3
- gluon-nlp/scripts/question_answering/train.py HOT 2
- XLMR Conversion fails on parameter dictionary KeyError HOT 3
- I want BigRNN back... HOT 5
- Difference in naming convention between op.py and test_op.py
- Implementation of Incremental Decoding
- Wrong ETA for max_seq_length != 512
- Wheel fails to build setup.py for gluonnlp HOT 2
- (not a bug) question about bert `create_pretraining_data.tokenize_lines()` HOT 1
- ImportError [...]/lib/python3.10/site-packages/gluonnlp/data/fast_bert_tokenizer.cpython-310-x86_64-linux-gnu.so: undefined symbol: _PyGen_Send HOT 5
- Problems not being imported from colab HOT 1
- nlp version error HOT 1
- Installation Error in google Collab env with Python3.7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gluon-nlp.