本文整理匯總了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)