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


Python DB.finishLoadingTrainingset方法代碼示例

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


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

示例1: load

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishLoadingTrainingset [as 別名]
    def load(self, project):
        print 'data load...'

        if self.offline:
            d = self.gen_samples_offline(
                        nsamples=self.n_train_samples,
                        purpose='train',
                        patchSize=self.project.patchSize,
                        mean=self.project.mean,
                        std=self.project.std)
            self.x = d[0]
            self.y = d[1]

            d = self.gen_samples_offline(
                        nsamples=self.n_valid_samples,
                        purpose='validate',
                        patchSize=self.project.patchSize,
                        mean=d[2],
                        std=d[3])
            self.x_valid = d[0]
            self.y_valid = d[1]

            print 'x:', np.shape(self.x)
            print 'y:', np.shape(self.y)
            print 'xvalid:', np.shape(self.x_valid)
            print 'yvalid:', np.shape(self.y_valid)

        else:
            self.load_validation()
            self.load_training()

        DB.finishLoadingTrainingset( project.id )
開發者ID:thouis,項目名稱:icon,代碼行數:34,代碼來源:data.py

示例2: aload

# 需要導入模塊: from db import DB [as 別名]
# 或者: from db.DB import finishLoadingTrainingset [as 別名]
    def aload(self, project):

        self.projecft = project

        # LOAD TRAINING DATA 
        train_new = len(self.entries) > 0
        images = DB.getImages( project.id, purpose=0, new=train_new)
        out = self.load_data(
                Paths.TrainGrayscale, 
                images, 
                project, 
                self.x, 
                self.y,
                self.p, 
                self.entries)

        self.x = out[0]
        self.y = out[1]
        self.p = out[2]
        self.entries = out[3]

        n_samples = len(self.y)
        self.i = np.arange( n_samples )
        self.n_superbatch = int(n_samples/(Data.TrainSuperBatchSize + Data.ValidSuperBatchSize))
        self.i_randomize  = 0 
        self.data_changed = True
        self.i_train = []
        self.avg_losses = []
        self.last_avg_loss = 0 

        if n_samples >  0:  
            Utility.report_status('---------training---------', '') 
            Utility.report_status('#samples','(%d)'%len(self.y))
            Utility.report_status('x shape','(%d,%d)'%(self.x.shape[0], self.x.shape[1]))
            Utility.report_status('y shape','(%d)'%(self.x.shape[0]))
            Utility.report_status('x memory', '(%d bytes)'%(self.x.nbytes))
            Utility.report_status('y memory', '(%d bytes)'%(self.y.nbytes))

        print 'min:', np.min( self.x )
        print 'max:', np.max( self.x )
        print 'uy:', np.unique( self.y )
        print 'x:', self.x[:5]
        print 'y:', self.y[:5]


        # LOAD VALIDATION IMAGES
        valid_new = len(self.entries_valid) > 0
        images = DB.getImages( project.id, purpose=1, new=valid_new )
        out = self.load_data(   
                Paths.ValidGrayscale, 
                images, 
                project, 
                self.x_valid, 
                self.y_valid, 
                self.p_valid,
                self.entries_valid)

        self.x_valid = out[0]
        self.y_valid = out[1]
        self.p_valid = out[2]
        self.entries_valid = out[3]

        n_samples = len(self.y_valid)
        self.i_valid = np.arange( n_samples )

        if n_samples >  0:
            Utility.report_status('---------validation---------', '')
            Utility.report_status('#samples','(%d)'%len(self.y_valid))
            Utility.report_status('x shape','(%d,%d)'%(self.x_valid.shape[0], self.x_valid.shape[1]))
            Utility.report_status('y shape','(%d)'%(self.x_valid.shape[0]))
            Utility.report_status('x memory', '(%d bytes)'%(self.x_valid.nbytes))
            Utility.report_status('y memory', '(%d bytes)'%(self.y_valid.nbytes))

        print 'min:', np.min( self.x_valid )
        print 'max:', np.max( self.x_valid )
        print 'uy:', np.unique( self.y_valid )
        print 'x:', self.x_valid[:5]
        print 'y:', self.y_valid[:5]

        Utility.report_memused()
        DB.finishLoadingTrainingset( project.id )
開發者ID:thouis,項目名稱:icon,代碼行數:83,代碼來源:data.py


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