def __call__(self, xs, ts, ys): counts = DFCounts() for x, t, y in zip(xs, ts, ys): generator_seg = self.generate_lines_seg(x, t, y) generator_tag = self.generate_lines(x, t, y) counts.l1 = conlleval.evaluate(generator_seg, counts=counts.l1) counts.l2 = conlleval.evaluate(generator_tag, counts=counts.l2) return counts
def __call__(self, xs, ts, ys): counts = FCounts() for x, t, y in zip(xs, ts, ys): generator = self.generate_lines(x, t, y) counts = conlleval.evaluate(generator, counts=counts) return counts
def evaluate(model, data, batch_size, log): was_training = model.training model.eval() pred = [] gold = [] with torch.no_grad(): for pa in data_generator(data, batch_size): x = pa[0] y = pa[1] slot = pa[2] _x, _y, p = model(x, y, slot, 'test') gold += _y pred += p if was_training: model.train() _gold = [] _pred = [] for i in gold: for j in i: _gold.append(j) for i in pred: for j in i: _pred.append(j) return conlleval.evaluate(_gold, _pred, log, verbose=True)
def __call__(self, xs, t1s, t2s, y1s, y2s): counts = FACounts() if not t2s or not y2s: t2s = [None] * len(xs) y2s = [None] * len(xs) for x, t1, t2, y1, y2 in zip(xs, t1s, t2s, y1s, y2s): generator_seg = self.generate_lines_seg(x, t1, y1) counts.l1 = conlleval.evaluate(generator_seg, counts=counts.l1) if t2 is not None: for ti, yi in zip(t2, y2): counts.l2.total += 1 if ti == yi: counts.l2.correct += 1 return counts