No silent error when d_head already in the configuration (#4747)

* No silent error when d_head already in the configuration

* Update src/transformers/configuration_xlnet.py

Co-authored-by: Julien Chaumond <chaumond@gmail.com>

Co-authored-by: Julien Chaumond <chaumond@gmail.com>
This commit is contained in:
Lysandre Debut 2020-06-05 12:01:43 -04:00 committed by GitHub
parent b9109f2de1
commit 79ab881eb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -163,6 +163,10 @@ class XLNetConfig(PretrainedConfig):
self.n_layer = n_layer
self.n_head = n_head
assert d_model % n_head == 0
if "d_head" in kwargs:
assert kwargs["d_head"] == d_model // n_head, (
f"`d_head` ({kwargs['d_head']}) should be equal to `d_model // n_head` ({d_model // n_head})"
)
self.d_head = d_model // n_head
self.ff_activation = ff_activation
self.d_inner = d_inner