(self, data)
return txt, txt_len
Move data to device, insert <sos> and compute text seq. length
Move data to device, insert <sos> and compute text seq. length
Move data to device insert <sos > and compute text seq . length
def fetch_data(self, data):
        ''' Move data to device, insert <sos> and compute text seq. length'''
        txt = torch.cat(
            (torch.zeros((data.shape[0], 1), dtype=torch.long), data), dim=1).to(self.device)
        txt_len = torch.sum(data != 0, dim=-1)
        return txt, txt_len
def fetch_data ( self , data ) : txt = torch . cat ( ( torch . zeros ( ( data . shape [ 0 ] , 1 ) , dtype = torch . long ) , data ) , dim = 1 ) . to ( self . device ) txt_len = torch . sum ( data != 0 , dim = - 1 ) return txt , txt_len