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


Python DB.finishSaveModel方法代碼示例

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


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

示例1: save

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishSaveModel [as 別名]
    def save(self, best=False):
        print 'Model.save()'

        if self.model == None:
            return False

        name   = '%s_%s'%(self.project.id, self.project.type)
        prefix = 'best' if best else 'latest'
       
        revision = 0
 
        if self.offline:
            name = '%s_offline'%(name)
        elif best:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            prefix   = '%s_%d'%(prefix, revision)

        # construct the path to the network and weights
        path = '%s/%s_%s'%(Paths.Models, prefix, name)
        j_path = '%s.json'%(path)
        w_path = '%s_weights.h5'%(path)

        j_path = j_path.lower()
        w_path = w_path.lower()

        print 'saving model...'
        json_string = self.model.to_json()
        open(j_path, 'w').write(json_string)
        self.model.save_weights(w_path, overwrite=True)

        if not self.offline:
            DB.finishSaveModel( self.project.id, revision )

        return True
開發者ID:Rhoana,項目名稱:icon,代碼行數:37,代碼來源:model.py

示例2: save

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishSaveModel [as 別名]
    def save(self, best=False):
        print 'Model.save()'

        if self.model == None:
            return False

        j_path, w_path, rev = self.get_paths(forSaving=True, forBest=best)

        print 'saving model...'
        json_string = self.model.to_json()
        open(j_path, 'w').write(json_string)
        self.model.save_weights(w_path, overwrite=True)

        if not self.offline:
            DB.finishSaveModel( self.project.id, rev )

        return True
開發者ID:Rhoana,項目名稱:icon,代碼行數:19,代碼來源:unet.py

示例3: save

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishSaveModel [as 別名]
    def save(self):
        path = self.path

        revision = 0
        if not self.offline:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            path = '%s/best_%s.%s.%d.pkl'%(Paths.Models, self.id, self.type, revision)
            path = path.lower()

        print 'saving...', path
        with open(path, 'wb') as file:
            cPickle.dump((
                self.hiddenLayers, 
                self.logRegressionLayer, 
                self.n_in, 
                self.n_hidden), file)

        if not self.offline:
            DB.finishSaveModel( self.id, revision )
開發者ID:Rhoana,項目名稱:icon,代碼行數:22,代碼來源:mlp.py

示例4: save_best

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishSaveModel [as 別名]
    def save_best(self):
        print 'Unet.save'
        path = Utility.get_dir(self.path)
        revision = 0
        if not self.offline:
            revision = DB.getRevision( self.id )
            revision = (revision+1)%10
            path = '%s/%s_%s_%d'%(Paths.Models, self.id, self.type, revision)
            path = path.lower()

        j_path = '%s_best.json'%(path)
        w_path = '%s_best_weights.h5'%(path)
        j_path = j_path.lower()
        w_path = w_path.lower()

        print 'saving...', path
        # saving code here...
        json_string = self.model.to_json()
        open(j_path, 'w').write(json_string)
        self.model.save_weights(w_path, overwrite=True)

        if not self.offline:
            DB.finishSaveModel( self.id, revision )
開發者ID:Rhoana,項目名稱:icon,代碼行數:25,代碼來源:oldunet2.py


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