当前位置: 首页>>代码示例>>Python>>正文


Python cntk.sigmoid方法代码示例

本文整理汇总了Python中cntk.sigmoid方法的典型用法代码示例。如果您正苦于以下问题:Python cntk.sigmoid方法的具体用法?Python cntk.sigmoid怎么用?Python cntk.sigmoid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cntk的用法示例。


在下文中一共展示了cntk.sigmoid方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_model

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def create_model(features):
    '''
    This function creates the architecture model.
    :param features: The input features.
    :return: The output of the network which its dimentionality is num_classes.
    '''
    with C.layers.default_options(init = C.layers.glorot_uniform(), activation = C.ops.relu):

            # Hidden input dimention
            hidden_dim = 64

            # Encoder
            encoder_out = C.layers.Dense(hidden_dim, activation=C.relu)(features)
            encoder_out = C.layers.Dense(int(hidden_dim / 2.0), activation=C.relu)(encoder_out)

            # Decoder
            decoder_out = C.layers.Dense(int(hidden_dim / 2.0), activation=C.relu)(encoder_out)
            decoder_out = C.layers.Dense(hidden_dim, activation=C.relu)(decoder_out)
            decoder_out = C.layers.Dense(feature_dim, activation=C.sigmoid)(decoder_out)

            return decoder_out

# Initializing the model with normalized input. 
开发者ID:astorfi,项目名称:CNTK-World,代码行数:25,代码来源:autoencoders.py

示例2: test_sigmoid

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def test_sigmoid():
    assert_cntk_ngraph_isclose(C.sigmoid([-2, -1., 0., 1., 2.]))
    assert_cntk_ngraph_isclose(C.sigmoid([0.]))
    assert_cntk_ngraph_isclose(C.exp([-0.9, -0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0.])) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:6,代码来源:test_ops_unary.py

示例3: sigmoid

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def sigmoid(x):
    return C.sigmoid(x) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:cntk_backend.py

示例4: binary_crossentropy

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def binary_crossentropy(target, output, from_logits=False):
    if from_logits:
        output = C.sigmoid(output)
    output = C.clip(output, epsilon(), 1.0 - epsilon())
    output = -target * C.log(output) - (1.0 - target) * C.log(1.0 - output)
    return output 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:cntk_backend.py

示例5: create_model

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [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
#-------------------------------------- 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:39,代码来源:train_end2end.py

示例6: D

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def D(x_img, x_code):
    '''
    Detector network architecture

    Args:
        x_img: cntk.input_variable represent images to network
        x_code: cntk.input_variable represent conditional code to network
    '''
    def bn_with_leaky_relu(x, leak=0.2):
        h = C.layers.BatchNormalization(map_rank=1)(x)
        r = C.param_relu(C.constant((np.ones(h.shape) * leak).astype(np.float32)), h)
        return r

    with C.layers.default_options(init=C.normal(scale=0.02)):

        h0 = C.layers.Convolution2D(dkernel, 1, strides=dstride)(x_img)
        h0 = bn_with_leaky_relu(h0, leak=0.2)
        print('h0 shape :', h0.shape)

        h1 = C.layers.Convolution2D(dkernel, 64, strides=dstride)(h0)
        h1 = bn_with_leaky_relu(h1, leak=0.2)
        print('h1 shape :', h1.shape)

        h2 = C.layers.Dense(256, activation=None)(h1)
        h2 = bn_with_leaky_relu(h2, leak=0.2)
        print('h2 shape :', h2.shape)

        h2_aug = C.splice(h2, x_code)

        h3 = C.layers.Dense(256, activation=C.relu)(h2_aug)

        h4 = C.layers.Dense(1, activation=C.sigmoid, name='D_out')(h3)
        print('h3 shape :', h4.shape)

        return h4 
开发者ID:astorfi,项目名称:CNTK-World,代码行数:37,代码来源:conditional-DCGAN.py

示例7: binary_crossentropy

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import sigmoid [as 别名]
def binary_crossentropy(output, target, from_logits=False):
    if from_logits:
        output = C.sigmoid(output)
    output = C.clip(output, _EPSILON, 1.0 - _EPSILON)
    output = -target * C.log(output) - (1.0 - target) * C.log(1.0 - output)
    return output 
开发者ID:sunilmallya,项目名称:keras-lambda,代码行数:8,代码来源:cntk_backend.py


注:本文中的cntk.sigmoid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。