當前位置: 首頁>>代碼示例>>Python>>正文


Python cntk.__version__方法代碼示例

本文整理匯總了Python中cntk.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python cntk.__version__方法的具體用法?Python cntk.__version__怎麽用?Python cntk.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cntk的用法示例。


在下文中一共展示了cntk.__version__方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import __version__ [as 別名]
def init():
    try:
        print("Executing init() method...")
        print("Python version: " + str(sys.version) + ", CNTK version: " + cntk.__version__)
    except Exception as e:
        print("Exception in init:")
        print(str(e))


################
# Main
################ 
開發者ID:Azure-Samples,項目名稱:MachineLearningSamples-ImageClassificationUsingCntk,代碼行數:14,代碼來源:deploymain.py

示例2: _get_cntk_version

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import __version__ [as 別名]
def _get_cntk_version():
    version = C.__version__
    if version.endswith('+'):
        version = version[:-1]
    # for hot fix, ignore all the . except the first one.
    if len(version) > 2 and version[1] == '.':
        version = version[:2] + version[2:].replace('.', '')
    try:
        return float(version)
    except:
        warnings.warn(
            'CNTK backend warning: CNTK version not detected. '
            'Will using CNTK 2.0 GA as default.')
        return float(2.0) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:16,代碼來源:cntk_backend.py

示例3: _get_cntk_version

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import __version__ [as 別名]
def _get_cntk_version():
    version = C.__version__
    if version.endswith('+'):
        version = version[:-1]
    try:
        return float(version)
    except:
        warnings.warn(
            'CNTK backend warning: CNTK version not detected. '
            'Will using CNTK 2.0 GA as default.')
        return float(2.0) 
開發者ID:sheffieldnlp,項目名稱:deepQuest,代碼行數:13,代碼來源:cntk_backend.py

示例4: run

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import __version__ [as 別名]
def run(input_df):
    try:
        print("Python version: " + str(sys.version) + ", CNTK version: " + cntk.__version__)

        startTime = dt.datetime.now()
        print(str(input_df))

        # convert input back to image and save to disk
        base64ImgString = input_df['image base64 string'][0]
        print(base64ImgString)
        pil_img = base64ToPilImg(base64ImgString)
        print("pil_img.size: " + str(pil_img.size))
        pil_img.save(imgPath, "JPEG")
        print("Save pil_img to: " + imgPath)

        # Load model (once then keep in memory)
        print("Classifier = " + classifier)
        makeDirectory(workingDir)
        if not os.path.exists(cntkRefinedModelPath):
            raise Exception("Model file {} does not exist, likely because the {} classifier has not been trained yet.".format(cntkRefinedModelPath, classifier))
        if not ('model' in vars() or 'model' in globals()):
            model = load_model(cntkRefinedModelPath)
            lutId2Label = readPickle(lutId2LabelPath)

        # Run DNN
        printDeviceType()
        node = getModelNode(classifier)
        mapPath = pathJoin(workingDir, "rundnn_map.txt")
        dnnOutput = runCntkModelImagePaths(model, [imgPath], mapPath, node, run_mbSize)

        # Predicted labels and scores
        scoresMatrix = runClassifierOnImagePaths(classifier, dnnOutput, svmPath, svm_boL2Normalize)
        scores = scoresMatrix[0]
        predScore = np.max(scores)
        predLabel = lutId2Label[np.argmax(scores)]
        print("Image predicted to be '{}' with score {}.".format(predLabel, predScore))

        # Create json-encoded string of the model output
        executionTimeMs = (dt.datetime.now() - startTime).microseconds / 1000
        outDict = {"label": str(predLabel), "score": str(predScore), "allScores": str(scores),
                   "Id2Labels": str(lutId2Label), "executionTimeMs": str(executionTimeMs)}
        outJsonString = json.dumps(outDict)
        print("Json-encoded detections: " + outJsonString[:120] + "...")
        print("DONE.")

        return(str(outJsonString))

    except Exception as e:
        return(str(e))

# API initialization method 
開發者ID:Azure-Samples,項目名稱:MachineLearningSamples-ImageClassificationUsingCntk,代碼行數:53,代碼來源:deploymain.py


注:本文中的cntk.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。