Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
  • Loading branch information
narumiruna committed Jun 21, 2024
1 parent a3099bc commit bbbe5b1
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ exclude = ["build"]
line-length = 120

[tool.ruff.lint]
ignore = [
"N812", # lowercase-imported-as-non-lowercase
]
select = [
"B", # flake8-bugbear
"C", # flake8-comprehensions
Expand Down
2 changes: 1 addition & 1 deletion template/datasets/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ def __init__(self, root: str, train: bool, batch_size: int, **kwargs):

dataset = datasets.MNIST(root, train=train, transform=transform, download=True)

super(MNISTDataLoader, self).__init__(dataset=dataset, batch_size=batch_size, shuffle=train, **kwargs)
super().__init__(dataset=dataset, batch_size=batch_size, shuffle=train, **kwargs)
4 changes: 2 additions & 2 deletions template/models/lenet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ConvBNReLU(nn.Sequential):
def __init__(self, in_channels, out_channels, kernel_size):
super(ConvBNReLU, self).__init__(
super().__init__(
nn.Conv2d(in_channels, out_channels, kernel_size, bias=False),
nn.BatchNorm2d(out_channels),
nn.ReLU(inplace=True),
Expand All @@ -14,7 +14,7 @@ def __init__(self, in_channels, out_channels, kernel_size):
@register
class LeNet(nn.Module):
def __init__(self):
super(LeNet, self).__init__()
super().__init__()
self.features = nn.Sequential(
ConvBNReLU(1, 6, 5),
nn.MaxPool2d(2, 2),
Expand Down
8 changes: 4 additions & 4 deletions template/trainers/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def fit(self) -> None:
}
wandb.log(metrics, step=epoch)

format_string = "Epoch: {}/{}, ".format(epoch, self.num_epochs)
format_string += "train loss: {:.4f}, train acc: {:.4f}, ".format(train_loss, train_acc)
format_string += "test loss: {:.4f}, test acc: {:.4f}, ".format(test_loss, test_acc)
format_string += "best test acc: {:.4f}.".format(self.best_acc)
format_string = f"Epoch: {epoch}/{self.num_epochs}, "
format_string += f"train loss: {train_loss:.4f}, train acc: {train_acc:.4f}, "
format_string += f"test loss: {test_loss:.4f}, test acc: {test_acc:.4f}, "
format_string += f"best test acc: {self.best_acc:.4f}."
tqdm.write(format_string)

self.state["epoch"] = epoch
Expand Down
4 changes: 2 additions & 2 deletions template/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def manual_seed(seed=0):


def load_yaml(f):
with open(f, "r") as fp:
with open(f) as fp:
return yaml.safe_load(fp)


Expand All @@ -25,7 +25,7 @@ def save_yaml(data, f, **kwargs):

def load_json(f):
data = None
with open(f, "r") as fp:
with open(f) as fp:
data = json.load(fp)
return data

Expand Down

0 comments on commit bbbe5b1

Please sign in to comment.