Exemplo n.º 1
0
import json
import numpy as np
import torch
import torch.nn as nn
from collections import namedtuple
from copy import deepcopy
from torch.nn.utils import clip_grad_norm_
from torch.optim import Adam, SGD
from utils.io_ import seeds, Writer, get_logger, Index2Instance, prepare_data, write_extra_labels
from utils.models.sequence_tagger import Sequence_Tagger
from utils import load_word_embeddings
from utils.tasks.seqeval import accuracy_score, f1_score, precision_score, recall_score

uid = uuid.uuid4().hex[:6]

logger = get_logger('SequenceTagger')


def read_arguments():
    args_ = argparse.ArgumentParser(description='Sovling SequenceTagger')
    args_.add_argument('--dataset',
                       choices=['ontonotes', 'ud'],
                       help='Dataset',
                       required=True)
    args_.add_argument('--domain', help='domain', required=True)
    args_.add_argument('--rnn_mode',
                       choices=['RNN', 'LSTM', 'GRU'],
                       help='architecture of rnn',
                       required=True)
    args_.add_argument('--task',
                       default='distance_from_the_root',
import numpy as np
import torch
import torch.nn as nn
from collections import namedtuple
from utils.io_ import seeds, Writer, get_logger, prepare_data, rearrange_splits
from utils.models.parsing_gating import BiAffine_Parser_Gated
from utils import load_word_embeddings
from utils.tasks import parse
import time
from torch.nn.utils import clip_grad_norm_
from torch.optim import Adam, SGD
import uuid

uid = uuid.uuid4().hex[:6]

logger = get_logger('GraphParser')


def read_arguments():
    args_ = argparse.ArgumentParser(description='Sovling GraphParser')
    args_.add_argument('--dataset',
                       choices=['ontonotes', 'ud'],
                       help='Dataset',
                       required=True)
    args_.add_argument('--domain', help='domain/language', required=True)
    args_.add_argument('--rnn_mode',
                       choices=['RNN', 'LSTM', 'GRU'],
                       help='architecture of rnn',
                       required=True)
    args_.add_argument('--gating',
                       action='store_true',
Exemplo n.º 3
0
import numpy as np
import torch
import torch.nn as nn
from collections import namedtuple
from utils.io_ import seeds, Writer, get_logger, prepare_data, rearrange_splits
from utils.models.parsing_gating import BiAffine_Parser_Gated
from utils import load_word_embeddings
from utils.tasks import parse
import os
from subprocess import Popen, PIPE, run
from torch.nn.utils import clip_grad_norm_
from torch.optim import Adam, SGD

uid = uuid.uuid4().hex[:6]

logger = get_logger('GraphParser_for_DA')


def read_arguments():
    args_ = argparse.ArgumentParser(description='Sovling GraphParser_for_DA')
    args_.add_argument('--dataset',
                       choices=['ud', 'ontonotes'],
                       help='Dataset',
                       required=True)
    args_.add_argument('--src_domain',
                       help='source domain/language',
                       required=True)
    args_.add_argument('--tgt_domain',
                       help='target domain/language',
                       required=True)
    args_.add_argument('--rnn_mode',