mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Summary: This reverts commit 60a889494d2e2f4df1d720331e19f638c5eb95cc Differential Revision: D5159712 fbshipit-source-id: 16040c911b260648857f656f92b165f92c2daae0
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from __future__ import absolute_import
|
|
from __future__ import division
|
|
from __future__ import print_function
|
|
from __future__ import unicode_literals
|
|
|
|
import unittest
|
|
from caffe2.python import brew, model_helper
|
|
from caffe2.python.modeling.initializers import Initializer
|
|
|
|
|
|
class InitializerTest(unittest.TestCase):
|
|
def test_fc_initializer(self):
|
|
model = model_helper.ModelHelper(name="test")
|
|
data = model.net.AddExternalInput("data")
|
|
fc1 = brew.fc(model, data, "fc1", dim_in=1, dim_out=1)
|
|
|
|
# no operator name set, will use default
|
|
fc2 = brew.fc(model, fc1, "fc2", dim_in=1, dim_out=1,
|
|
WeightInitializer=Initializer)
|
|
|
|
# no operator name set, will use custom
|
|
fc3 = brew.fc(model, fc2, "fc3", dim_in=1, dim_out=1,
|
|
WeightInitializer=Initializer,
|
|
weight_init=("ConstantFill", {}),
|
|
)
|
|
|
|
# operator name set, no initializer class set
|
|
fc4 = brew.fc(model, fc3, "fc4", dim_in=1, dim_out=1,
|
|
WeightInitializer=None,
|
|
weight_init=("ConstantFill", {})
|
|
)
|
|
|