diff --git a/misc/utils.py b/misc/utils.py index 611dbff..fa28a20 100644 --- a/misc/utils.py +++ b/misc/utils.py @@ -233,7 +233,7 @@ def __getattr__(self, name): class ReduceLROnPlateau(object): "Optim wrapper that implements rate." def __init__(self, optimizer, mode='min', factor=0.1, patience=10, verbose=False, threshold=0.0001, threshold_mode='rel', cooldown=0, min_lr=0, eps=1e-08): - self.scheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode, factor, patience, verbose, threshold, threshold_mode, cooldown, min_lr, eps) + self.scheduler = optim.lr_scheduler.ReduceLROnPlateau(optimizer, mode, factor, patience, threshold, threshold_mode, cooldown, min_lr, eps, verbose) self.optimizer = optimizer self.current_lr = get_lr(optimizer) diff --git a/models/AttModel.py b/models/AttModel.py index 02c3c9a..bda0e1a 100644 --- a/models/AttModel.py +++ b/models/AttModel.py @@ -31,6 +31,8 @@ def sort_pack_padded_sequence(input, lengths): sorted_lengths, indices = torch.sort(lengths, descending=True) + sorted_lengths=sorted_lengths.to(int) + tmp = pack_padded_sequence(input[indices], sorted_lengths.cpu(), batch_first=True) tmp = pack_padded_sequence(input[indices], sorted_lengths, batch_first=True) inv_ix = indices.clone() inv_ix[indices] = torch.arange(0,len(indices)).type_as(inv_ix) @@ -791,4 +793,4 @@ def core(self, xt, fc_feats, att_feats, p_att_feats, state, att_masks): def _prepare_feature(self, fc_feats, att_feats, att_masks): fc_feats = self.fc_embed(fc_feats) - return fc_feats, None, None, None \ No newline at end of file + return fc_feats, None, None, None