(self, dataset, callbacks)
Helper function for fit which performs training on a dataset for one epoch.

        Arguments:
            dataset (NervanaDataIterator): Dataset iterator to perform fit on
Helper function for fit which performs training on a dataset for one epoch.
Helper function for fit which performs training on a dataset for one epoch .
def _epoch_fit(self, dataset, callbacks):
        """
        Helper function for fit which performs training on a dataset for one epoch.

        Arguments:
            dataset (NervanaDataIterator): Dataset iterator to perform fit on
        """
        epoch = self.epoch_index
        self.total_cost[:] = 0
        # iterate through minibatches of the dataset
        for mb_idx, (x, t) in enumerate(dataset):
            callbacks.on_minibatch_begin(epoch, mb_idx)
            self.be.begin(Block.minibatch, mb_idx)

            x = self.fprop(x)

            self.total_cost[:] = self.total_cost + self.cost.get_cost(x, t)

            # deltas back propagate through layers
            # for every layer in reverse except the 0th one
            delta = self.cost.get_errors(x, t)

            self.bprop(delta)
            self.optimizer.optimize(self.layers_to_optimize, epoch=epoch)

            self.be.end(Block.minibatch, mb_idx)
            callbacks.on_minibatch_end(epoch, mb_idx)

        # now we divide total cost by the number of batches,
        # so it was never total cost, but sum of averages
        # across all the minibatches we trained on
        self.total_cost[:] = self.total_cost / dataset.nbatches
def _epoch_fit ( self , dataset , callbacks ) : epoch = self . epoch_index self . total_cost [ : ] = 0 # iterate through minibatches of the dataset for mb_idx , ( x , t ) in enumerate ( dataset ) : callbacks . on_minibatch_begin ( epoch , mb_idx ) self . be . begin ( Block . minibatch , mb_idx ) x = self . fprop ( x ) self . total_cost [ : ] = self . total_cost + self . cost . get_cost ( x , t ) # deltas back propagate through layers # for every layer in reverse except the 0th one delta = self . cost . get_errors ( x , t ) self . bprop ( delta ) self . optimizer . optimize ( self . layers_to_optimize , epoch = epoch ) self . be . end ( Block . minibatch , mb_idx ) callbacks . on_minibatch_end ( epoch , mb_idx ) # now we divide total cost by the number of batches, # so it was never total cost, but sum of averages # across all the minibatches we trained on self . total_cost [ : ] = self . total_cost / dataset . nbatches