Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ozancaglayan committed Apr 30, 2018
1 parent db10a66 commit c029c10
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion nmtpytorch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'device_id': 'auto_1', # auto_N for automatic N gpus
# 0,1,2 for manual N gpus
# 0 for 0th (single) GPU
'seed': 0, # > 0: only if you want to reproduce a previous experiment!
'seed': 0, # > 0 if you want to reproduce a previous experiment
'gclip': 5., # Clip gradients above clip_c
'l2_reg': 0., # L2 penalty factor
'patience': 20, # Early stopping patience
Expand Down
1 change: 0 additions & 1 deletion nmtpytorch/datasets/multilabelmulti30k.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from .collate import get_collate



class MultiLabelMulti30kDataset(object):
"""Returns a Dataset for multi-label Multi30k using raw JPG images.
Expand Down
1 change: 1 addition & 0 deletions nmtpytorch/layers/flatten.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import torch


class Flatten(torch.nn.Module):
"""A flatten module to squeeze single dimensions."""
def __init__(self):
Expand Down
5 changes: 2 additions & 3 deletions nmtpytorch/layers/simplegru_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import torch.nn.functional as F

from ..utils.data import to_var
from ..utils.nn import get_rnn_hidden_state
from . import FF, Attention


Expand Down Expand Up @@ -87,8 +86,8 @@ def f_init(self, ctx_dict):

elif self.dec_init == 'mean':
h_0 = self.ff_dec_init(
ctx.sum(0).div(ctx_mask.unsqueeze(-1).sum(0)) \
if ctx_mask is not None else ctx.mean(0))
ctx.sum(0).div(ctx_mask.unsqueeze(-1).sum(0))
if ctx_mask is not None else ctx.mean(0))
elif self.dec_init == 'max':
h_0 = self.ff_dec_init(ctx.max(0)[0])
elif self.dec_init == 'last':
Expand Down
1 change: 1 addition & 0 deletions nmtpytorch/models/nmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def set_defaults(self):
'max_trg_len': 80, # Reject sentences where target > 80
'direction': None, # Network directionality, i.e. en->de
}

def __init__(self, opts, logger=None):
super().__init__()
self.print = print if logger is None else logger.info
Expand Down
2 changes: 0 additions & 2 deletions nmtpytorch/models/sat.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
from ..layers import ImageEncoder, XuDecoder
from ..vocabulary import Vocabulary
from ..utils.topology import Topology

from ..datasets import Multi30kRawDataset

Expand Down
2 changes: 1 addition & 1 deletion nmtpytorch/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(self, **kwargs):
def test(self, instance, split):
instance.load_data(split)
loader = instance.datasets[split].get_iterator(
self.batch_size, inference=True)
self.batch_size, inference=True)

self.logger.info('Starting computation')
start = time.time()
Expand Down

0 comments on commit c029c10

Please sign in to comment.