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


Python Error.resetLast方法代码示例

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


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

示例1: Lgreedy

# 需要导入模块: from error import Error [as 别名]
# 或者: from error.Error import resetLast [as 别名]
def Lgreedy(G, M, errorEnc, time, struc, totalCostOld, Eold, model_cost_struct): 

    toKeep = 'true';
    old_numUnmodelledErrors = Eold.numUnmodelledErrors;
    if time == 1:
        E = Error(G); # initially, everything is error, nothing is covered
        #E.saveOld();
        # the cost for encoding each structure (to avoid recomputing it for the greedy updates)
        model_cost2 = 0;
    else :
        E = Eold; #Error(G, Eold);
        # clear the temp vars that keep the diff in the Error by adding the new structure
        E.resetLast();
        #E.deepish_copy(Eold);
        #E = copy.deepcopy(Eold);
        #E = Eold;
        # the cost for encoding each structure separately 
        # Just update the up-to-now cost by adding the cost of the new structure
        model_cost2 = model_cost_struct;

    error_cost = 0;
    repeatedEdges = 0;
    repeatedErrors = 0;
    

    model_cost = LN(M.numStructs+1);    # encode number of structures we're encoding with
    model_cost += LwC(M.numStructs, M.numStrucTypes);            # encode the number per structure

    # encode the structure-type identifier per type
    if M.numFullCliques > 0 :
        model_cost += M.numFullCliques * log(M.numFullCliques / float(M.numStructs), 2);
    if M.numNearCliques  > 0 :
        model_cost += M.numNearCliques * log(M.numNearCliques / float(M.numStructs), 2);
    if M.numChains > 0 :
        model_cost += M.numChains * log(M.numChains / float(M.numStructs), 2);
    if M.numStars > 0 :
        model_cost += M.numStars * log(M.numStars / float(M.numStructs), 2);
    # off-diagonals
    if M.numFullOffDiagonals > 0 :
        model_cost += M.numFullOffDiagonals * log(M.numFullOffDiagonals / float(M.numStructs), 2);
    if M.numNearOffDiagonals > 0 :
        model_cost += M.numNearOffDiagonals * log(M.numNearOffDiagonals / float(M.numStructs), 2);
    # bipartite-cores
    if M.numBiPartiteCores > 0 :
        model_cost += M.numBiPartiteCores * log(M.numBiPartiteCores / float(M.numStructs), 2);
    if M.numNearBiPartiteCores > 0 :
        model_cost += M.numNearBiPartiteCores * log(M.numNearBiPartiteCores / float(M.numStructs), 2);
    if M.numJellyFishes > 0 :
        model_cost += M.numJellyFishes * log(M.numJellyFishes / float(M.numStructs), 2);
    if M.numCorePeripheries > 0 :
        model_cost += M.numCorePeripheries * log(M.numCorePeripheries / float(M.numStructs), 2);

    # encode the structures
    if struc.isFullClique() :
        (cost,repeatedEdges,repeatedErrors) = LfullClique(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isNearClique() :
        (cost,repeatedEdges,repeatedErrors) = LnearClique(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isChain() :
        (cost,repeatedEdges,repeatedErrors) = Lchain(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isStar() :
        (cost,repeatedEdges,repeatedErrors) = Lstar(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isCorePeriphery() :
        (cost,repeatedEdges,repeatedErrors) = LcorePeriphery(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isJellyFish() :
        (cost,repeatedEdges,repeatedErrors) = LjellyFish(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isBiPartiteCore() :
        (cost,repeatedEdges,repeatedErrors) = LbiPartiteCore(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isNearBiPartiteCore() :
        (cost,repeatedEdges,repeatedErrors) = LnearBiPartiteCore(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isFullOffDiagonal() :
        (cost,repeatedEdges,repeatedErrors) = LfullOffDiagonal(struc,M,G,E);
        model_cost2 += cost;
    elif struc.isNearOffDiagonal() :
        (cost,repeatedEdges,repeatedErrors) = LnearOffDiagonal(struc,M,G,E);
        model_cost2 += cost;

    #print ">>>> repeated_errors = %.0f,\trepeated_edges = %.0f\tcovered = %.0f\tnewly_covered = %.0f" % (repeatedErrors,repeatedEdges,G.numEdges - E.numUnmodelledErrors, old_numUnmodelledErrors - E.numUnmodelledErrors); 
    #print ">?>? previously_covered = %.0f,\tnow_covered = %.0f" %(G.numEdges - old_numUnmodelledErrors, G.numEdges - E.numUnmodelledErrors);   

    # encode the error
    error_cost += 0 if E.numCellsCovered == 0 else log(E.numCellsCovered, 2);    # encode number of additive Errors
    if ((G.numNodes * G.numNodes - G.numNodes) / 2) - E.numCellsCovered > 0 :
        error_cost += log(((G.numNodes * G.numNodes - G.numNodes) / 2) - E.numCellsCovered, 2);    # encode number of Errors
 
    if errorEnc == "NP" :
        error_cost += LErrorNaivePrefix(G,M,E);
    elif errorEnc == "NB" :
        error_cost += LErrorNaiveBinom(G,M,E);
    elif errorEnc == "TP" :
        error_cost += LErrorTypedPrefix(G,M,E);
    elif errorEnc == "TB" :
        error_cost += LErrorTypedBinom(G,M,E);
#.........这里部分代码省略.........
开发者ID:yikeliu,项目名称:ConDeNSe,代码行数:103,代码来源:mdl.py


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