when i run my project,there show that “an interger is required(got type list)”,i know maybe i need to change my data type,but yesterday there is no wrong,I don’t know how to do that
the error
image990×219 4.22 KB
def flatten_list_of_lists(list_of_lists):


list_of_lists = [[]] + list_of_lists                               
offsets = np.cumsum([len(x) for x in list_of_lists])[:-1]                
flatten = sum(list_of_lists[1:], [])                            

return flatten, offsets*emphasized text*

========================================================================
token_ids = [l + m + r if len(l) + len(r) > 0 else [self.prerank_model.word_voca.unk_id] for l, m, r in zip(lctx_ids, ment_ids, rctx_ids)]                            

entity_ids = [m['cands'] for m in content]                                                    

entity_ids = Variable(torch.LongTensor(entity_ids))

entity_mask = [m['mask'] for m in content]                                                            
entity_mask = Variable(torch.FloatTensor(entity_mask))
token_ids, token_offsets = utils.flatten_list_of_lists(token_ids)                                
token_offsets=token_offsets/1.0

token_offsets = Variable(torch.LongTensor(token_offsets))

token_ids = Variable(torch.LongTensor(token_ids))
print("token_ids",type(token_ids))