Build one batch
(data,
batch_index,
conf,
turn_cut_type='tail',
term_cut_type='tail')
| 116 | |
| 117 | |
| 118 | def 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 | |
| 151 | def build_one_batch_dict(data, |
no test coverage detected