當前位置: 首頁>>代碼示例>>Python>>正文


Python initializers.GlorotUniform方法代碼示例

本文整理匯總了Python中chainer.initializers.GlorotUniform方法的典型用法代碼示例。如果您正苦於以下問題:Python initializers.GlorotUniform方法的具體用法?Python initializers.GlorotUniform怎麽用?Python initializers.GlorotUniform使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在chainer.initializers的用法示例。


在下文中一共展示了initializers.GlorotUniform方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def __init__(self, in_size, out_size=None, nobias=True, initialW=None,
                 initial_bias=None):
        super(GraphConvolution, self).__init__()

        if out_size is None:
            in_size, out_size = None, in_size
        self.out_size = out_size

        with self.init_scope():
            if initialW is None:
                initialW = initializers.GlorotUniform()
            self.W = chainer.Parameter(initialW, (in_size, out_size))
            if nobias:
                self.b = None
            else:
                if initial_bias is None:
                    initial_bias = 0
                bias_initializer = initializers._get_initializer(initial_bias)
                self.b = chainer.Parameter(bias_initializer, out_size) 
開發者ID:koreyou,項目名稱:text-gcn-chainer,代碼行數:21,代碼來源:nets.py

示例2: create_initializer

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def create_initializer(init_type, scale=None, fillvalue=None):
    if init_type == 'identity':
        return initializers.Identity() if scale is None else initializers.Identity(scale=scale)
    if init_type == 'constant':
        return initializers.Constant(fillvalue)
    if init_type == 'zero':
        return initializers.Zero()
    if init_type == 'one':
        return initializers.One()
    if init_type == 'normal':
        return initializers.Normal() if scale is None else initializers.Normal(scale)
    if init_type == 'glorotNormal':
        return initializers.GlorotNormal() if scale is None else initializers.GlorotNormal(scale)
    if init_type == 'heNormal':
        return initializers.HeNormal() if scale is None else initializers.HeNormal(scale)
    if init_type == 'orthogonal':
        return initializers.Orthogonal(
            scale) if scale is None else initializers.Orthogonal(scale)
    if init_type == 'uniform':
        return initializers.Uniform(
            scale) if scale is None else initializers.Uniform(scale)
    if init_type == 'leCunUniform':
        return initializers.LeCunUniform(
            scale) if scale is None else initializers.LeCunUniform(scale)
    if init_type == 'glorotUniform':
        return initializers.GlorotUniform(
            scale) if scale is None else initializers.GlorotUniform(scale)
    if init_type == 'heUniform':
        return initializers.HeUniform(
            scale) if scale is None else initializers.HeUniform(scale)
    raise ValueError("Unknown initializer type: {0}".format(init_type)) 
開發者ID:fabiencro,項目名稱:knmt,代碼行數:33,代碼來源:rnn_cells.py

示例3: get_initializers

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def get_initializers(self):
        if self.initialW == 'zero':
            weight_initializer = initializers.constant.Zero()
        elif self.initialW == 'random':
            weight_initializer = initializers.GlorotUniform(
                rng=numpy.random.RandomState(seed=0))

        if self.initial_bias == 'zero':
            bias_initializer = initializers.constant.Zero()
        elif self.initial_bias == 'random':
            bias_initializer = initializers.Uniform(
                rng=numpy.random.RandomState(seed=0))

        return weight_initializer, bias_initializer 
開發者ID:chainer,項目名稱:chainer,代碼行數:16,代碼來源:test_link_n_step_rnn.py

示例4: setUp

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def setUp(self):
        self.n_label = 3
        self.initial_cost = numpy.empty((self.n_label, self.n_label),
                                        dtype=self.dtype)

        if self.initializer is None:
            initializer = initializers.constant.Zero()

        elif self.initializer == 'random':
            initializer = initializers.GlorotUniform()

        initializer(self.initial_cost)
        with chainer.using_config('dtype', self.dtype):
            self.link = links.CRF1d(self.n_label,
                                    initial_cost=self.initial_cost) 
開發者ID:chainer,項目名稱:chainer,代碼行數:17,代碼來源:test_crf1d.py

示例5: __init__

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def __init__(self, num_heads, size, dropout_ratio=0.1):
        super().__init__()
        assert size % num_heads == 0, "model size must be divisible by the number of heads"

        self.key_dimensionality = size // num_heads
        self.num_heads = num_heads
        self.attention = None
        self.dropout_ratio = dropout_ratio

        with self.init_scope():
            self.linears = L.Linear(size, size, initialW=initializers.GlorotUniform()).repeat(4, mode='init') 
開發者ID:chainer,項目名稱:models,代碼行數:13,代碼來源:attention.py

示例6: __init__

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def __init__(self, size, vocab_size):
        super().__init__()
        self.size = size

        with self.init_scope():
            self.embed = L.EmbedID(vocab_size, size, initialW=initializers.GlorotUniform()) 
開發者ID:chainer,項目名稱:models,代碼行數:8,代碼來源:embedding.py

示例7: __init__

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def __init__(self, size, ff_size=2048, dropout_ratio=0.1):
        super().__init__()
        self.dropout_ratio = dropout_ratio
        with self.init_scope():
            self.l1 = L.Linear(size, ff_size, initialW=initializers.GlorotUniform())
            self.l2 = L.Linear(ff_size, size, initialW=initializers.GlorotUniform()) 
開發者ID:chainer,項目名稱:models,代碼行數:8,代碼來源:position_wise_feed_forward.py

示例8: __init__

# 需要導入模塊: from chainer import initializers [as 別名]
# 或者: from chainer.initializers import GlorotUniform [as 別名]
def __init__(self, num_heads, size, dropout_ratio=0.1):
        super().__init__()
        assert size % num_heads == 0, "model size must be divisable by the number of heads"

        self.key_dimensionality = size // num_heads
        self.num_heads = num_heads
        self.attention = None
        self.dropout_ratio = dropout_ratio

        with self.init_scope():
            self.linears = L.Linear(size, size, initialW=initializers.GlorotUniform()).repeat(4, mode='init') 
開發者ID:Bartzi,項目名稱:kiss,代碼行數:13,代碼來源:attention.py


注:本文中的chainer.initializers.GlorotUniform方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。