This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
import os | |
import numpy as np | |
# settings for GPU | |
os.environ["CUDA_VISIBLE_DEVICES"] = "0" | |
config = tf.ConfigProto() | |
config.gpu_options.allow_growth = True | |
config.gpu_options.per_process_gpu_memory_fraction = 0.9 | |
sess = tf.Session(config=config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence | |
import random | |
import numpy as np | |
import re, unicodedata | |
random.seed(1024) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import logging | |
import os | |
import shutil | |
import torch | |
import torch.utils.data as data | |
import config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pickle | |
train_x_file = "./data/train_x" | |
train_y_file = "./data/train_y" | |
dev_x_file = "./data/dev_x" | |
dev_y_file = "./data/dev_y" | |
input_file = "./data/input.pkl" | |
label_file = "./data/label.pkl" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
from pytorch_pretrained_bert.tokenization import whitespace_tokenize | |
import collections | |
from copy import deepcopy | |
class SquadExample(object): | |
""" | |
A single training/test example for the Squad dataset. | |
For examples without an answer, the start and end position are -1. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
from pytorch_pretrained_bert import BertTokenizer | |
import random | |
import numpy as np | |
from squad_utils import convert_examples_to_features, read_squad_examples | |
import config | |
tokenizer = BertTokenizer.from_pretrained("bert-base-uncased", do_lower_case=True) | |
train_examples = read_squad_examples("./squad/train-v1.1.json", is_training=True, debug=False) | |
train_features = convert_examples_to_features(train_examples, tokenizer=tokenizer, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<better case> | |
golden: when did abc first start ? | |
dual: when was abc originally launched by edward j . noble ? | |
base: what is the name of abc ' s radio network ? | |
golden : what kind of markets did nbc red serve ? | |
dual: when was nbc red served by nbc red ? | |
base: when was the nbc blue network created ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
import json | |
import re | |
import string | |
import sys | |
import torch | |
from pytorch_pretrained_bert import BertForQuestionAnswering, BertTokenizer | |
from torch.utils.data import SequentialSampler, DataLoader, TensorDataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from model import Seq2seq | |
import os | |
from squad_utils import read_squad_examples, convert_examples_to_features, write_predictions | |
from pytorch_pretrained_bert import BertTokenizer, BertForQuestionAnswering | |
import torch | |
from torch.utils.data import DataLoader, TensorDataset | |
import torch.nn.functional as F | |
import config | |
import collections | |
import re, string, sys, json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# old files | |
train_src_file = "./squad/para-train.txt" | |
train_trg_file = "./squad/tgt-train.txt" | |
dev_src_file = "./squad/para-dev.txt" | |
dev_trg_file = "./squad/tgt-dev.txt" | |
test_src_file = "./squad/para-test.txt" | |
test_trg_file = "./squad/tgt-test.txt" | |
embedding = "./data/embedding.pkl" | |
word2idx_file = "./data/word2idx.pkl" |
OlderNewer