mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
Kaiming Initialization (#14718)
Summary: /cc goldsborough Working on #14582 The corresponding python implementations are at: [pytorch/torch/nn/init.py](https://github.com/pytorch/pytorch/blob/6302e4001ab54b3ddeca2b608d337fe7077e801c/torch/nn/init.py#L261-L327) Here is my initial implementation of Kaiming Initialization. I have not been able to figure out how to successfully run tests locally so I haven't added any yet. A couple questions: - Are the enums defined in the right place? I copied their names from Python, but do you prefer different naming conventions for C++? - To run tests locally do I use `python setup.py test`? Can I run just a subset of the tests somehow? - Should I add my tests at [test/cpp/api/misc.cpp](https://github.com/pytorch/pytorch/blob/master/test/cpp/api/misc.cpp#L47-L54)? Pull Request resolved: https://github.com/pytorch/pytorch/pull/14718 Differential Revision: D14049159 Pulled By: goldsborough fbshipit-source-id: 966ac5126875936e69b185b5041f16476ed4cf70
This commit is contained in:
committed by
Facebook Github Bot
parent
5eee0670ab
commit
1cdcdd78af
+1
-10
@@ -41,13 +41,4 @@ TEST_F(AutogradTest, CanTakeDerivativesOfZeroDimTensors) {
|
||||
TEST_F(AutogradTest, CanPassCustomGradientInputs) {
|
||||
z.sum().backward(torch::ones({}) * 2);
|
||||
ASSERT_TRUE(x.grad().allclose(y * 2));
|
||||
}
|
||||
|
||||
TEST(NNInitTest, CanInitializeTensorThatRequiresGrad) {
|
||||
auto tensor = torch::empty({3, 4}, torch::requires_grad());
|
||||
ASSERT_THROWS_WITH(
|
||||
tensor.fill_(1),
|
||||
"a leaf Variable that requires grad "
|
||||
"has been used in an in-place operation");
|
||||
ASSERT_EQ(torch::nn::init::ones_(tensor).sum().item<int32_t>(), 12);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user