Loading caption-lib/lstm/Readers/basic_text_reader.py +24 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,30 @@ def read_input(filename): Create sequences and save them ''' def create_sequences(filename): return True with open(inputPath + filename,"r") as file: text=file.read() formated_text_1=re.sub("\n","<EOS><>",text) formated_text_2=re.sub("<EOS><><EOS><>","<EOS><>",formated_text_1) all_sequences=formated_text_2.split("<>") return all_sequences def create_batches(all_sequences): batches=[] start=0 batch_size=config.trainer.batch_size for i in range(0,len(all_sequences),batch_size): batch=all_sequences[start:i+batchsize] batches.append(batch) start+=batchsize start=0 while [] in batches: batches.remove([]) return batches ''' Create vocabulary while reading files Loading Loading
caption-lib/lstm/Readers/basic_text_reader.py +24 −1 Original line number Diff line number Diff line Loading @@ -51,7 +51,30 @@ def read_input(filename): Create sequences and save them ''' def create_sequences(filename): return True with open(inputPath + filename,"r") as file: text=file.read() formated_text_1=re.sub("\n","<EOS><>",text) formated_text_2=re.sub("<EOS><><EOS><>","<EOS><>",formated_text_1) all_sequences=formated_text_2.split("<>") return all_sequences def create_batches(all_sequences): batches=[] start=0 batch_size=config.trainer.batch_size for i in range(0,len(all_sequences),batch_size): batch=all_sequences[start:i+batchsize] batches.append(batch) start+=batchsize start=0 while [] in batches: batches.remove([]) return batches ''' Create vocabulary while reading files Loading