當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。