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


Python Utility.report_memused方法代码示例

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


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

示例1: load_training

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import report_memused [as 别名]

#.........这里部分代码省略.........
            # skip if no annotations found
            if n_data == 0:
                continue

            # add sample to the training set
            if offset == 0:
                x = x_data
                y = y_data
                p = np.ones( n_data, dtype=np.int )
            else:
                x = np.vstack( (x, x_data) )
                y = np.hstack( (y, y_data) )
                p = np.hstack( (p, np.ones( n_data, dtype=np.int )) ) 

            # keep track of each image's data in an entry for 
            # easier replacement.
            entries.append( Entry( image.id, offset, n_data ) )

            #Utility.report_memused()
            Utility.report_status('x', '(%d bytes)'%(x.nbytes))
            Utility.report_status('y', '(%d bytes)'%(y.nbytes))
            Utility.report_status('.','.')


        # bailout if no entries found
        if len(entries) == 0:
            Utility.report_status('Fetching new data', 'None Found')
            return

        Utility.report_status( 'Loading new data', 'please wait')

        # bailout if no current entries
        if len(self.entries) > 0:
            #append old entries after the new entries
            offset = len(y)

            print entries[-1].name, entries[-1].offset, entries[-1].length
            mask = np.ones( len(self.y), dtype=bool)
            names = [ e.name for e in entries ]

            for entry in self.entries:
                if entry.name in names:
                    mask[ entry.offset : entry.offset+entry.length ] = False
                else:
                    entry.offset = offset
                    offset += entry.length
                    entries.append( entry )
                    print entry.name, entry.offset, entry.length

            x_keep = self.x[ mask ]
            y_keep = self.y[ mask ]
            p_keep = self.p[ mask ]
            x = np.vstack( (x, x_keep) )
            y = np.hstack( (y, y_keep) )
            p = np.hstack( (p, p_keep) )

        
        if len( np.unique( y ) ) <= 1:
            print 'not enough labels specified...'
            return

        n_data = len(y)
        #DB.finishLoadingTrainingset( project.id )


        print '=>n_data:', n_data

        # save the data
        self.x = x
        self.y = y
        self.p = p
        self.n_train = min(Data.TrainSuperBatchSize, n_data)
        #self.n_train = self.get_size( self.n_train )
        self.n_train = min(self.n_train, Data.MaxTrainSuperBatchSize)

        print 'n_train:', self.n_train, Data.TrainSuperBatchSize

        self.i =  np.random.choice(n_data, n_data, replace=False) 

        #self.i_valid = self.i[:self.ValidSuperBatchSize]
        #self.n_valid = len(self.i_valid)

        self.i_batch = 0
        self.n_batches = n_data/self.n_train

        self.entries = entries
        self.i_randomize  = 0
        self.data_changed = True
        self.i_train = []
        self.avg_losses = []
        self.last_avg_loss = 0

        Utility.report_status('.','.')
        Utility.report_status('loading complete','.')
        Utility.report_status('#samples','(%d)'%(n_data))
        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))
        Utility.report_memused()
开发者ID:thouis,项目名称:icon,代码行数:104,代码来源:data.py

示例2: load_validation

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import report_memused [as 别名]

#.........这里部分代码省略.........

        # Load training samples for each image.
        for image in images:

            Utility.report_status( 'loading validation image', image.id)
            print 'ttime:', image.trainingTime
            print 'atime:', image.annotationTime
            print 'tstat:', image.trainingStatus

            offset = len( entries )

            # generate samples for the image
            #data   = self.gen_samples( project, image.id, n_samples_per_image )
            data   = self.gen_samples( Paths.ValidGrayscale, self.project, image.id, n_samples_per_image )
            x_data = data[0]
            y_data = data[1]
            n_data = len( y_data )

            # skip if no annotations found
            if n_data == 0:
                continue

            # add sample to the training set
            if offset == 0:
                x = x_data
                y = y_data
                p = np.ones( n_data, dtype=np.int )
            else:
                x = np.vstack( (x, x_data) )
                y = np.hstack( (y, y_data) )
                p = np.hstack( (p, np.ones( n_data, dtype=np.int )) )

            # keep track of each image's data in an entry for 
            # easier replacement.
            entries.append( Entry( image.id, offset, n_data ) )

            #Utility.report_memused()
            Utility.report_status('x', '(%d bytes)'%(x.nbytes))
            Utility.report_status('y', '(%d bytes)'%(y.nbytes))
            Utility.report_status('.','.')



        # bailout if no entries found
        if len(entries) == 0:
            Utility.report_status('Fetching new data', 'None Found')
            return

        Utility.report_status( 'Loading new data', 'please wait')

        # bailout if no current entries
        if len(self.entries_valid) > 0:
            #append old entries after the new entries
            offset = len(y)

            print entries[-1].name, entries[-1].offset, entries[-1].length
            mask = np.ones( len(self.y_valid), dtype=bool)
            names = [ e.name for e in entries ]

            for entry in self.entries_valid:
                if entry.name in names:
                    mask[ entry.offset : entry.offset+entry.length ] = False
                else:
                    entry.offset = offset
                    offset += entry.length
                    entries.append( entry )
                    print entry.name, entry.offset, entry.length

            x_keep = self.x_valid[ mask ]
            y_keep = self.y_valid[ mask ]
            p_keep = self.p_valid[ mask ]
            x = np.vstack( (x, x_keep) )
            y = np.hstack( (y, y_keep) )
            p = np.hstack( (p, p_keep) )


        if len( np.unique( y ) ) <= 1:
            print 'not enough labels specified...'
            return

        n_data = len(y)

        # save the data
        self.x_valid = x
        self.y_valid = y
        self.p_valid = p
        self.entries_valid = entries
        #self.i_valid = np.random.choice(n_data, Data.ValidSuperBatchSize, replace=False)
        self.n_valid = min(Data.ValidSuperBatchSize, n_data)
        self.i_valid = np.random.choice(n_data, self.n_valid)

        Utility.report_status('.','.')
        Utility.report_status('loading complete','.')
        Utility.report_status('#samples','(%d)'%(n_data))
        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))
        Utility.report_memused()
        self.data_changed = True
开发者ID:thouis,项目名称:icon,代码行数:104,代码来源:data.py

示例3: aload

# 需要导入模块: from utility import Utility [as 别名]
# 或者: from utility.Utility import report_memused [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


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