mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
Rename embedding variable to weight (#9720)
Summary: I renamed the variable in the `Embedding` module from `weight` to `table` a few months ago, because it seemed like a more meaningful name. Turns out it's not such a good idea because it deviates from PyTorch, which unnecessarily breaks C++->Python translated code. ebetica ezyang apaszke Pull Request resolved: https://github.com/pytorch/pytorch/pull/9720 Differential Revision: D8955647 Pulled By: goldsborough fbshipit-source-id: 77228b07d2b733866e8cdecaa6d0686eef4cc3ea
This commit is contained in:
committed by
Facebook Github Bot
parent
431415adc4
commit
31ba2f15e1
@@ -142,8 +142,13 @@ TEST_CASE("modules") {
|
||||
|
||||
SECTION("embedding") {
|
||||
SECTION("basic") {
|
||||
int dict_size = 10;
|
||||
const int64_t dict_size = 10;
|
||||
Embedding model(dict_size, 2);
|
||||
REQUIRE(model->parameters().contains("weight"));
|
||||
REQUIRE(model->weight.ndimension() == 2);
|
||||
REQUIRE(model->weight.size(0) == dict_size);
|
||||
REQUIRE(model->weight.size(1) == 2);
|
||||
|
||||
// Cannot get gradients to change indices (input) - only for embedding
|
||||
// params
|
||||
auto x = torch::full({10}, dict_size - 1, torch::kInt64);
|
||||
@@ -156,7 +161,7 @@ TEST_CASE("modules") {
|
||||
REQUIRE(y.size(0) == 10);
|
||||
REQUIRE(y.size(1) == 2);
|
||||
|
||||
REQUIRE(model->parameters()["table"].grad().numel() == 2 * dict_size);
|
||||
REQUIRE(model->parameters()["weight"].grad().numel() == 2 * dict_size);
|
||||
}
|
||||
|
||||
SECTION("list") {
|
||||
|
||||
Reference in New Issue
Block a user