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


Python cntk.combine方法代码示例

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


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

示例1: init

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import combine [as 别名]
def init():
    """ Initialise ResNet 152 model
    """
    global trainedModel, labelLookup, mem_after_init

    start = t.default_timer()

    # Load the model and labels from disk
    with open(LABEL_FILE, 'r') as f:
        labelLookup = [l.rstrip() for l in f]

    # Load model and load the model from brainscript (3rd index)
    trainedModel = load_model(MODEL_FILE)
    trainedModel = combine([trainedModel.outputs[3].owner])
    end = t.default_timer()

    loadTimeMsg = "Model loading time: {0} ms".format(round((end - start) * 1000, 2))
    logger.info(loadTimeMsg) 
开发者ID:Azure,项目名称:DevOps-For-AI-Apps,代码行数:20,代码来源:driver.py

示例2: audio_encoder_3

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import combine [as 别名]
def audio_encoder_3(input, model_file, cloning=False):
    # Load and freeze pre-trained encoder
    last_layer_name = "t_conv3"
    model = C.load_model(model_file)
    input_node = model.find_by_name("input")
    last_conv = model.find_by_name(last_layer_name)
    if not last_conv:
        raise ValueError("the layer does not exist")
    h = C.combine([last_conv.owner]).clone(C.CloneMethod.clone if cloning else C.CloneMethod.freeze, {input_node: input})
    return h 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:12,代码来源:train_end2end.py

示例3: create_criterion_function

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import combine [as 别名]
def create_criterion_function(model):
        labels = C.placeholder(name='labels')
        ce = C.cross_entropy_with_softmax(model, labels)
        errs = C.classification_error(model, labels)
        return C.combine([ce, errs])  # (features, labels) -> (loss, metric) 
开发者ID:singnet,项目名称:nlp-services,代码行数:7,代码来源:language_understanding.py

示例4: create_model

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import combine [as 别名]
def create_model(model_details, num_classes, input_features, new_prediction_node_name="prediction", freeze=False):
    # Load the pre-trained classification net and find nodes
    base_model = cntk.load_model(model_details["model_file"])

    feature_node = cntk.logging.find_by_name(base_model, model_details["feature_node_name"])
    last_node = cntk.logging.find_by_name(base_model, model_details["last_hidden_node_name"])

    if model_details["inception"]:
        node_outputs = cntk.logging.get_node_outputs(base_model)
        last_node = node_outputs[5]
        feature_node = cntk.logging.find_all_with_name(base_model, "")[-5]
    if model_details["vgg"]:
        last_node = cntk.logging.find_by_name(base_model, "prob")
        feature_node = cntk.logging.find_by_name(base_model, "data")

    # Clone the desired layers with fixed weights
    cloned_layers = cntk.combine([last_node.owner]).clone(
        cntk.CloneMethod.freeze if freeze else cntk.CloneMethod.clone,
        {feature_node: cntk.placeholder(name="features")},
    )

    # Add new dense layer for class prediction
    feat_norm = input_features - cntk.Constant(114)
    cloned_out = cloned_layers(feat_norm)
    z = cntk.layers.Dense(num_classes, activation=None, name=new_prediction_node_name)(cloned_out)
    return z


# Trains a transfer learning model 
开发者ID:singnet,项目名称:dnn-model-services,代码行数:31,代码来源:models_setup.py

示例5: stop_gradient

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import combine [as 别名]
def stop_gradient(variables):
    return C.stop_gradient(C.combine(variables)) 
开发者ID:sunilmallya,项目名称:keras-lambda,代码行数:4,代码来源:cntk_backend.py


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