本文整理汇总了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)
示例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))
示例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
示例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)
示例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')
示例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())
示例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())
示例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')