MCPcopy Create free account
hub / github.com/PaddlePaddle/Research / build_one_batch

Function build_one_batch

NLP/ACL2018-DAM/reader.py:118–148  ·  view source on GitHub ↗

Build one batch

(data,
                    batch_index,
                    conf,
                    turn_cut_type='tail',
                    term_cut_type='tail')

Source from the content-addressed store, hash-verified

116
117
118def build_one_batch(data,
119 batch_index,
120 conf,
121 turn_cut_type='tail',
122 term_cut_type='tail'):
123 """
124 Build one batch
125 """
126 _turns = []
127 _tt_turns_len = []
128 _every_turn_len = []
129
130 _response = []
131 _response_len = []
132
133 _label = []
134
135 for i in six.moves.xrange(conf['batch_size']):
136 index = batch_index * conf['batch_size'] + i
137 y, nor_turns_nor_c, nor_r, turn_len, term_len, r_len = produce_one_sample(
138 data, index, conf['_EOS_'], conf['max_turn_num'],
139 conf['max_turn_len'], turn_cut_type, term_cut_type)
140
141 _label.append(y)
142 _turns.append(nor_turns_nor_c)
143 _response.append(nor_r)
144 _every_turn_len.append(term_len)
145 _tt_turns_len.append(turn_len)
146 _response_len.append(r_len)
147
148 return _turns, _tt_turns_len, _every_turn_len, _response, _response_len, _label
149
150
151def build_one_batch_dict(data,

Callers 2

build_one_batch_dictFunction · 0.85
build_batchesFunction · 0.85

Calls 2

produce_one_sampleFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected