nlpmodels/utils/train.py
def _reformat_data(self, data: Tuple) -> gpt_batch.GPTBatch:
        """
        A generic function to reformat data for the problem.

        In this case, it's moving the data to the correct device, then creating a batch object.

        Args:
            data (Tuple): The tuples of LongTensors to be converted into a Batch object.
        Returns:
            GPTBatch object containing data for a given batch.
        """
        # (batch,seq) shape tensors
        source_integers, target_integers = data

        # place data on the correct device
        source_integers = source_integers.to(self._device)
        target_integers = target_integers.to(self._device)

        # return a batch object with src,src_mask,tgt,tgt_mask tensors
        batch_data = gpt_batch.GPTBatch(source_integers,
                                        target_integers,
                                        self._vocab.mask_index)

        return batch_data

        A generic function to reformat data for the problem.

        In this case, it's moving the data to the correct device, then creating a batch object.

        Args:
            data (Tuple): The tuples of LongTensors to be converted into a Batch object.
        Returns:
            GPTBatch object containing data for a given batch.
        
A generic function to reformat data for the problem.
In this case, it's moving the data to the correct device, then creating a batch object.
A generic function to reformat data for the problem . In this case it ' s moving the data to the correct device then creating a batch object .
def _reformat_data(self, data: Tuple) -> gpt_batch.GPTBatch:
        source_integers, target_integers = data
        source_integers = source_integers.to(self._device)
        target_integers = target_integers.to(self._device)
        batch_data = gpt_batch.GPTBatch(source_integers,
                                        target_integers,
                                        self._vocab.mask_index)
        return batch_data
def _reformat_data ( self , data : Tuple ) -> gpt_batch . GPTBatch : source_integers , target_integers = data source_integers = source_integers . to ( self . _device ) target_integers = target_integers . to ( self . _device ) batch_data = gpt_batch . GPTBatch ( source_integers , target_integers , self . _vocab . mask_index ) return batch_data
A generic function to reformat data for the problem.
A generic function to reformat data for the problem .
"""
        A generic function to reformat data for the problem.

        In this case, it's moving the data to the correct device, then creating a batch object.

        Args:
            data (Tuple): The tuples of LongTensors to be converted into a Batch object.
        Returns:
            GPTBatch object containing data for a given batch.
        """ # (batch,seq) shape tensors # place data on the correct device # return a batch object with src,src_mask,tgt,tgt_mask tensors
GPTBatch object containing data for a given batch.
GPTBatch object containing data for a given batch .
self
data
Tuple
The tuples of LongTensors to be converted into a Batch object.
The tuples of LongTensors to be converted into a Batch object .