Skip to content

Commit 0f3a584

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 69e217a commit 0f3a584

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+88
-58
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ repos:
2020
hooks:
2121
- id: black
2222
exclude: ^tests/
23-
args: [ --safe, --quiet ]
23+
args: [ --safe, --quiet ]

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
author = "Atharva Phatak"
3535

3636
# The full version, including alpha/beta/rc tags
37-
with open("../../version.txt", "r") as f:
37+
with open("../../version.txt") as f:
3838
release = str(f.readline().strip())
3939

4040

examples/Advanced-Tutorials/KD/vanilla-kd.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Vanilla Knowledge distillation using Torchflare.
22
This example only shows how to modify the training script for KD.
33
"""
4+
45
from typing import Dict
56

67
import torch
@@ -11,7 +12,7 @@
1112

1213
class KDExperiment(Experiment):
1314
def __init__(self, temperature, alpha, **kwargs):
14-
super(KDExperiment, self).__init__(**kwargs)
15+
super().__init__(**kwargs)
1516
self.temperature = temperature
1617
self.alpha = alpha
1718

examples/Advanced-Tutorials/autoencoders/mnist-vae.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generating MNIST digits using Variational Autoencoders."""
2+
23
import torch
34
import torch.nn.functional as F
45
from torch import nn
@@ -15,13 +16,13 @@ def __init__(self, d):
1516
super().__init__()
1617
self.d = d
1718
self.encoder = nn.Sequential(
18-
nn.Linear(784, self.d ** 2), nn.ReLU(), nn.Linear(self.d ** 2, self.d * 2)
19+
nn.Linear(784, self.d**2), nn.ReLU(), nn.Linear(self.d**2, self.d * 2)
1920
)
2021

2122
self.decoder = nn.Sequential(
22-
nn.Linear(self.d, self.d ** 2),
23+
nn.Linear(self.d, self.d**2),
2324
nn.ReLU(),
24-
nn.Linear(self.d ** 2, 784),
25+
nn.Linear(self.d**2, 784),
2526
nn.Sigmoid(),
2627
)
2728

examples/Advanced-Tutorials/gans/dcgan.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Generating MNIST Digits using DCGAN."""
2+
23
import os
34

45
import torch
@@ -20,7 +21,7 @@ def __init__(self, latent_dim, batchnorm=True):
2021
latent_dim (int): latent dimension ("noise vector")
2122
batchnorm (bool): Whether or not to use batch normalization
2223
"""
23-
super(Generator, self).__init__()
24+
super().__init__()
2425
self.latent_dim = latent_dim
2526
self.batchnorm = batchnorm
2627
self._init_modules()
@@ -77,7 +78,7 @@ def __init__(self, output_dim):
7778
Images must be single-channel and 28x28 pixels.
7879
Output activation is Sigmoid.
7980
"""
80-
super(Discriminator, self).__init__()
81+
super().__init__()
8182
self.output_dim = output_dim
8283
self._init_modules() # I know this is overly-organized. Fight me.
8384

@@ -127,7 +128,7 @@ def forward(self, input_tensor):
127128
class DCGANExperiment(Experiment):
128129
def __init__(self, latent_dim, batch_size, **kwargs):
129130

130-
super(DCGANExperiment, self).__init__(**kwargs)
131+
super().__init__(**kwargs)
131132

132133
self.noise_fn = lambda x: torch.randn((x, latent_dim), device=self.device)
133134
self.target_ones = torch.ones((batch_size, 1), device=self.device)

examples/Advanced-Tutorials/self-supervision/ssl_byol.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def default_augmentation(image_size: Tuple[int, int] = (224, 224)) -> nn.Module:
6565
# Defining the models.
6666
class MLPHead(nn.Module):
6767
def __init__(self, in_channels: int, projection_size: int = 256, hidden_size: int = 4096):
68-
super(MLPHead, self).__init__()
68+
super().__init__()
6969

7070
self.net = nn.Sequential(
7171
nn.Linear(in_channels, hidden_size),
@@ -81,7 +81,7 @@ def forward(self, x):
8181
# Defining resnet encoders.
8282
class ResnetEncoder(nn.Module):
8383
def __init__(self, pretrained, mlp_params):
84-
super(ResnetEncoder, self).__init__()
84+
super().__init__()
8585
resnet = torchvision.models.resnet18(pretrained=pretrained)
8686
self.encoder = torch.nn.Sequential(*list(resnet.children())[:-1])
8787
self.projector = MLPHead(in_channels=resnet.fc.in_features, **mlp_params)
@@ -95,7 +95,7 @@ def forward(self, x):
9595
# Defining custom training method required as required by Bootstrap your own latent.(SSL)
9696
class BYOLExperiment(Experiment):
9797
def __init__(self, momentum, augmentation_fn, image_size, **kwargs):
98-
super(BYOLExperiment, self).__init__(**kwargs)
98+
super().__init__(**kwargs)
9999
self.momentum = momentum
100100
self.augmentation_fn = augmentation_fn(image_size)
101101

examples/Basic-Tutorials/fit_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
class Net(torch.nn.Module):
1616
def __init__(self, out_features):
17-
super(Net, self).__init__()
17+
super().__init__()
1818

1919
self.conv1 = nn.Sequential(
2020
nn.Conv2d(in_channels=1, out_channels=64, kernel_size=3, padding=1),

examples/Basic-Tutorials/text_classification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class Model(torch.nn.Module):
2020
def __init__(self, dropout, out_features):
2121

22-
super(Model, self).__init__()
22+
super().__init__()
2323
self.bert = transformers.BertModel.from_pretrained("prajjwal1/bert-tiny", return_dict=False)
2424
self.bert_drop = nn.Dropout(dropout)
2525
self.out = nn.Linear(128, out_features)

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Setup.py for torchflare."""
2+
23
# flake8: noqa
34
import os
45

@@ -15,15 +16,15 @@
1516

1617

1718
readme_file_path = os.path.join(current_file_path, "README.md")
18-
with open(readme_file_path, "r", encoding="utf-8") as f:
19+
with open(readme_file_path, encoding="utf-8") as f:
1920
readme = f.read()
2021

2122

2223
version_file_path = os.path.join(current_file_path, "version.txt")
23-
with open(version_file_path, "r", encoding="utf-8") as f:
24+
with open(version_file_path, encoding="utf-8") as f:
2425
version = f.read().strip()
2526

26-
with open(os.path.join(current_file_path, "requirements.txt"), "r") as f:
27+
with open(os.path.join(current_file_path, "requirements.txt")) as f:
2728
requirements = f.read().splitlines()
2829

2930

tests/experiment/test_experiment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
class Model(torch.nn.Module):
1515
def __init__(self, num_features, num_classes):
16-
super(Model, self).__init__()
16+
super().__init__()
1717
self.model = torch.nn.Linear(num_features, num_classes)
1818

1919
def forward(self, x):

0 commit comments

Comments
 (0)