Remove unused code

This commit is contained in:
Sina 2020-12-22 19:08:10 -08:00
parent d3d2d7c89f
commit bd0297e00c
6 changed files with 12 additions and 31 deletions

10
.gitignore vendored
View File

@ -1,33 +1,31 @@
# Byte-compiled / optimized / DLL files
__pycache__/
models/__pycache__/
*.py[cod]
*$py.class
# added manually
.data
.embeddings
__pycache__/
models/__pycache__/
multiprocess/__pycache__/
results/
tests/embeddings/*
local_files
local_scripts/*
dataset/*
generated/*
*events.out.tfevents*
.DS_Store
.idea/
.vscode/
models/.DS_Store
multiprocess/.DS_Store
text/.DS_Store
src/
workdir/
*save*/
lightning_logs/
pytorch_model.bin
*.pth
tests/embeddings/*
tests/dataset-*
tests/dataset/*
tests/database/*

View File

@ -77,21 +77,21 @@ def parse_argv(parser):
'If sentence_batching is used, this will be interpreted as number of examples.')
parser.add_argument('--jump_start', default=0, type=int, help='number of iterations to give jump started tasks')
parser.add_argument('--n_jump_start', default=0, type=int, help='how many tasks to jump start (presented in order)')
parser.add_argument('--num_print', default=15, type=int,
parser.add_argument('--num_print', default=10, type=int,
help='how many validation examples with greedy output to print to std out')
parser.add_argument('--no_tensorboard', action='store_false', dest='tensorboard',
help='Turn off tensorboard logging')
parser.add_argument('--tensorboard_dir', default=None,
help='Directory where to save Tensorboard logs (defaults to --save)')
parser.add_argument('--max_to_keep', default=5, type=int, help='number of checkpoints to keep')
parser.add_argument('--log_every', default=int(1e2), type=int, help='how often to log results in # of iterations')
parser.add_argument('--save_every', default=int(1e3), type=int,
parser.add_argument('--max_to_keep', default=3, type=int, help='number of checkpoints to keep')
parser.add_argument('--log_every', default=100, type=int, help='how often to log results in # of iterations')
parser.add_argument('--save_every', default=1000, type=int,
help='how often to save a checkpoint in # of iterations')
parser.add_argument('--val_tasks', nargs='+', type=str, dest='val_task_names',
help='tasks to collect evaluation metrics for')
parser.add_argument('--val_every', default=int(1e3), type=int,
parser.add_argument('--val_every', default=1000, type=int,
help='how often to run validation in # of iterations')
parser.add_argument('--val_batch_size', nargs='+', default=[3000], type=int,
help='Number of tokens in each batch for validation, corresponding to tasks in --val_tasks')

View File

@ -49,8 +49,6 @@ class Example(NamedTuple):
answer: str
context_plus_question: List[str]
vocab_fields = ['context', 'question', 'answer']
@staticmethod
def from_raw(example_id: str, context: str, question: str, answer: str, preprocess = identity, lower=False):
args = [example_id]

View File

@ -68,8 +68,8 @@ class MQANDecoder(nn.Module):
def forward(self, batch, final_context, context_rnn_state, encoder_loss,
current_token_id=None, decoder_wrapper=None, expansion_factor=1, generation_dict=None):
context, context_lengths, context_limited = batch.context.value, batch.context.length, batch.context.limited
answer, answer_lengths, answer_limited = batch.answer.value, batch.answer.length, batch.answer.limited
context, context_limited = batch.context.value, batch.context.limited
answer, answer_limited = batch.answer.value, batch.answer.limited
decoder_vocab = self.numericalizer.decoder_vocab
self.map_to_full = decoder_vocab.decode
context_padding = context.data == self.pad_idx

View File

@ -138,7 +138,6 @@ def train_step(model, batch, iteration, opt, devices, lr_scheduler=None, grad_cl
for p in model.parameters():
if p.grad is None:
continue
# print('p.grad = ', p.grad)
p.grad /= accumulated_batch_lengths
accumulated_batch_lengths = 0
if grad_clip > 0.0:
@ -367,8 +366,7 @@ def train(args, devices, model, opt, lr_scheduler, train_sets, train_iterations,
grad_clip=args.grad_clip,
gradient_accumulation_steps=args.gradient_accumulation_steps)
if loss is None:
logger.info(
'Encountered NAN loss during training... Continue training ignoring the current batch')
logger.info('Encountered NAN loss during training... Continue training ignoring the current batch')
continue
if loss < 1e-6:
zero_loss += 1

View File

@ -435,19 +435,6 @@ def make_data_loader(dataset, numericalizer, batch_size, device=None, train=Fals
return data_loader
def pad(x, new_channel, dim, val=None):
if x.size(dim) > new_channel:
x = x.narrow(dim, 0, new_channel)
channels = x.size()
assert (new_channel >= channels[dim])
if new_channel == channels[dim]:
return x
size = list(channels)
size[dim] = new_channel - size[dim]
padding = x.new(*size).fill_(val)
return torch.cat([x, padding], dim)
def have_multilingual(task_names):
return any(['multilingual' in name for name in task_names])