示例#1
0
def recorder(vals):
    for iis, fis, il, sl in vals:
        yield R.example({
            'int_img': R.ints_feat(iis),
            'flt_img': R.floats_feat(fis),
            'int_lbl': R.one_int_feat(il),
            'str_lbl': R.bytes_feat(sl),
        })
示例#2
0
def query_valid(topics):
    for t, c, q in topics.queries():
        yield R.example({
            'title': R.ints_feat([*t.title.toks]),
            'context': R.ints_feat([*c.toks]),
            'query': R.ints_feat([*q.toks]),
            'valid': R.one_int_feat(1 if q.valid else 0),
            'uid': R.bytes_feat(q.uid),
        })
示例#3
0
def possibles(topics):
    for t, c, q, p in topics.possibs():
        yield R.example({
            'title': R.ints_feat([*t.title.toks]),
            'context': R.ints_feat([*c.toks]),
            'query': R.ints_feat([*q.toks]),
            'possib': R.ints_feat([*p.toks]),
            'begin': R.one_int_feat(p.span.beg),
            'end': R.one_int_feat(p.span.end),
            'uid': R.bytes_feat(p.uid),
        })
示例#4
0
def reply_spans(topics):
    for t, c, q, r in topics.replies():
        yield R.example({
            'title': R.ints_feat([*t.title.toks]),
            'context': R.ints_feat([*c.toks]),
            'query': R.ints_feat([*q.toks]),
            'reply': R.ints_feat([*r.toks]),
            'begin': R.one_int_feat(r.span.beg),
            'end': R.one_int_feat(r.span.end),
            'uid': R.bytes_feat(r.uid),
        })
示例#5
0
 def record(self):
     return R.example({
         'toks':
         R.bytes_list_feat(self.by_idx[:self.max_used + 1]),
     })
示例#6
0
def recorder(topic):
    for _, c in topic.contexts():
        yield R.example({
            'context': R.ints_feat([*c.toks]),
            'uid': R.bytes_feat(c.uid),
        })