INNER CODE UNIT · Python

probs

IBM/transition-amr-parser · src/ibm_neural_aligner/main.py:618

            probs = [1 - args.mask, args.mask]
            size = len(x['amr_nodes'])
            mask = np.random.choice(tokens, p=probs, size=size).tolist()

            # If only 1 item, then never mask.
            if size == 1:
                mask[0] = MaskInfo.unchanged_and_predict

            # If nothing is masked, then always predict at least one item.
            if sum(mask) == 0:
                mask[np.random.randint(0, size)] = MaskInfo.unchanged_and_predict

            assert sum(mask) > 0

            m = torch.tensor(mask, dtype=torch.long)
            batch_mask.append(m)

            if args.add_edges:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…