本文整理匯總了Python中cntk.tanh方法的典型用法代碼示例。如果您正苦於以下問題:Python cntk.tanh方法的具體用法?Python cntk.tanh怎麽用?Python cntk.tanh使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cntk
的用法示例。
在下文中一共展示了cntk.tanh方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_tanh
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import tanh [as 別名]
def test_tanh():
assert_cntk_ngraph_isclose(C.tanh([-2, -1., 0., 1., 2.]))
assert_cntk_ngraph_isclose(C.tanh([0.]))
assert_cntk_ngraph_isclose(C.tanh([-0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.]))
示例2: tanh
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import tanh [as 別名]
def tanh(x):
return C.tanh(x)
示例3: create_model
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import tanh [as 別名]
def create_model(input, net_type="gru", encoder_type=1, model_file=None, e3cloning=False):
if encoder_type == 1:
h = audio_encoder(input)
if net_type.lower() is not "cnn":
h = flatten(h)
elif encoder_type == 2:
h = audio_encoder_2(input)
# pooling
h = C.layers.GlobalAveragePooling(name="avgpool")(h)
h = C.squeeze(h)
elif encoder_type == 3:
h = audio_encoder_3(input, model_file, e3cloning)
if net_type.lower() is not "cnn":
h = flatten(h)
else:
raise ValueError("encoder type {:d} not supported".format(encoder_type))
if net_type.lower() == "cnn":
h = C.layers.Dense(1024, init=C.he_normal(), activation=C.tanh)(h)
elif net_type.lower() == "gru":
h = C.layers.Recurrence(step_function=C.layers.GRU(256), go_backwards=False, name="rnn")(h)
elif net_type.lower() == "lstm":
h = C.layers.Recurrence(step_function=C.layers.LSTM(256), go_backwards=False, name="rnn")(h)
elif net_type.lower() == "bigru":
# bi-directional GRU
h = bi_recurrence(h, C.layers.GRU(128), C.layers.GRU(128), name="bigru")
elif net_type.lower() == "bilstm":
# bi-directional LSTM
h = bi_recurrence(h, C.layers.LSTM(128), C.layers.LSTM(128), name="bilstm")
h = C.layers.Dropout(0.2)(h)
# output
y = C.layers.Dense(label_dim, activation=C.sigmoid, init=C.he_normal(), name="output")(h)
return y
#--------------------------------------
# loss functions
#--------------------------------------