本文整理汇总了Python中cntk.parameter方法的典型用法代码示例。如果您正苦于以下问题:Python cntk.parameter方法的具体用法?Python cntk.parameter怎么用?Python cntk.parameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cntk
的用法示例。
在下文中一共展示了cntk.parameter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: random_uniform_variable
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def random_uniform_variable(shape, low, high,
dtype=None, name=None, seed=None):
if dtype is None:
dtype = floatx()
if seed is None:
# ensure that randomness is conditioned by the Numpy RNG
seed = np.random.randint(10e3)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
if name is None:
name = ''
scale = (high - low) / 2
p = C.parameter(
shape,
init=C.initializer.uniform(
scale,
seed=seed),
dtype=dtype,
name=name)
return variable(value=p.value + low + scale)
示例2: random_uniform_variable
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def random_uniform_variable(shape, low, high, dtype=_FLOATX,
name=None, seed=None):
if seed is None:
# ensure that randomness is conditioned by the Numpy RNG
seed = np.random.randint(10e3)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
if name is None:
name = ''
scale = (high - low) / 2
p = C.parameter(
shape,
init=C.initializer.uniform(
scale,
seed=seed),
dtype=dtype,
name=name)
return variable(value=p.value + low + scale)
示例3: random_normal_variable
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def random_normal_variable(
shape,
mean,
scale,
dtype=_FLOATX,
name=None,
seed=None):
if seed is None:
# ensure that randomness is conditioned by the Numpy RNG
seed = np.random.randint(10e7)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
if name is None:
name = ''
return C.parameter(
shape=shape,
init=C.initializer.normal(
scale=scale,
seed=seed),
dtype=dtype,
name=name)
示例4: linear_layer
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def linear_layer(input_var, output_dim):
input_dim = input_var.shape[0]
weight = C.parameter(shape=(input_dim, output_dim))
bias = C.parameter(shape=(output_dim))
return bias + C.times(input_var, weight)
示例5: linear_layer
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def linear_layer(input_var, output_dim):
input_dim = input_var.shape[0]
weight_param = C.parameter(shape=(input_dim, output_dim))
bias_param = C.parameter(shape=(output_dim))
return C.times(input_var, weight_param) + bias_param
示例6: random_normal_variable
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def random_normal_variable(
shape,
mean,
scale,
dtype=None,
name=None,
seed=None):
if dtype is None:
dtype = floatx()
if seed is None:
# ensure that randomness is conditioned by the Numpy RNG
seed = np.random.randint(10e7)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
if name is None:
name = ''
p = C.parameter(
shape=shape,
init=C.initializer.normal(
scale=scale,
seed=seed),
dtype=dtype,
name=name)
return variable(value=p.value + mean)
示例7: truncated_normal
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def truncated_normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None):
if seed is None:
seed = np.random.randint(1, 10e6)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
return C.parameter(
shape, init=C.initializer.truncated_normal(
stddev, seed=seed), dtype=dtype)
示例8: conv_from_weights
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def conv_from_weights(x, weights, bias=None, padding=True, name=""):
""" weights is a numpy array """
k = C.parameter(shape=weights.shape, init=weights)
y = C.convolution(k, x, auto_padding=[False, padding, padding])
if bias:
b = C.parameter(shape=bias.shape, init=bias)
y = y + bias
y = C.alias(y, name=name)
return y
# bi-directional recurrence function op
# fwd, bwd: a recurrent op, LSTM or GRU
示例9: random_normal_variable
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import parameter [as 别名]
def random_normal_variable(
shape,
mean,
scale,
dtype=None,
name=None,
seed=None):
if dtype is None:
dtype = floatx()
if seed is None:
# ensure that randomness is conditioned by the Numpy RNG
seed = np.random.randint(10e7)
if dtype is None:
dtype = np.float32
else:
dtype = _convert_string_dtype(dtype)
if name is None:
name = ''
return C.parameter(
shape=shape,
init=C.initializer.normal(
scale=scale,
seed=seed),
dtype=dtype,
name=name)