当前位置: 首页>>代码示例>>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;未经允许,请勿转载。