(self, callback_data, model, epochs)
Called when training is about to begin

        Arguments:
            callback_data (HDF5 dataset): shared data between callbacks
            model (Model): model object
            epochs (int): Total epochs
Called when training is about to begin
Called when training is about to begin
def on_train_begin(self, callback_data, model, epochs):
        """
        Called when training is about to begin

        Arguments:
            callback_data (HDF5 dataset): shared data between callbacks
            model (Model): model object
            epochs (int): Total epochs
        """
        # get number of costs
        assert isinstance(model.cost, Multicost), "Cost must be a Multicost"
        self.ncosts = len(model.cost.costs)
        # get number of nested-costs
        self.ncosts_allbranches = sum([self.recursive_multicost_len(c) for c in model.cost.costs])

        # preallocate space for the number of minibatches in the whole run
        points = callback_data['config'].attrs['total_minibatches']
        callback_data.create_dataset("multicost/train", (points, self.ncosts), dtype='float64')
        callback_data.create_dataset("multicost/train_allbranches",
                                     (points, self.ncosts_allbranches), dtype='float64')

        # make sure our window size is less than or equal to total number of minibatches
        self.wsz = min(points, self.wsz)
        self.cost_history = deque([], maxlen=int(self.wsz))

        # clue in the data reader to use the 'minibatch' time_markers
        callback_data['multicost/train'].attrs['time_markers'] = 'minibatch'
        callback_data['multicost/train_allbranches'].attrs['time_markers'] = 'minibatch'
def on_train_begin ( self , callback_data , model , epochs ) : # get number of costs assert isinstance ( model . cost , Multicost ) , "Cost must be a Multicost" self . ncosts = len ( model . cost . costs ) # get number of nested-costs self . ncosts_allbranches = sum ( [ self . recursive_multicost_len ( c ) for c in model . cost . costs ] ) # preallocate space for the number of minibatches in the whole run points = callback_data [ 'config' ] . attrs [ 'total_minibatches' ] callback_data . create_dataset ( "multicost/train" , ( points , self . ncosts ) , dtype = 'float64' ) callback_data . create_dataset ( "multicost/train_allbranches" , ( points , self . ncosts_allbranches ) , dtype = 'float64' ) # make sure our window size is less than or equal to total number of minibatches self . wsz = min ( points , self . wsz ) self . cost_history = deque ( [ ] , maxlen = int ( self . wsz ) ) # clue in the data reader to use the 'minibatch' time_markers callback_data [ 'multicost/train' ] . attrs [ 'time_markers' ] = 'minibatch' callback_data [ 'multicost/train_allbranches' ] . attrs [ 'time_markers' ] = 'minibatch'