Skip to content

Commit af2eadd

Browse files
committed
Remove redundant imports
1 parent c710e7a commit af2eadd

File tree

4 files changed

+6
-14
lines changed

4 files changed

+6
-14
lines changed

minitorch/autodiff.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass
2-
from typing import Any, Iterable, List, Tuple
2+
from typing import Any, Iterable, Tuple
33

44
from typing_extensions import Protocol
55

minitorch/nn/init.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import math
22

33

4-
def kaiming_uniform(tensor, fan_in, **kwargs):
4+
def kaiming_uniform(tensor, fan_in):
55
bound = math.sqrt(6 / fan_in)
66
tensor.uniform_(-bound, bound)
77

@@ -11,14 +11,14 @@ def glorot_uniform(tensor, fan_in, fan_out):
1111
tensor.uniform_(-bound, bound)
1212

1313

14-
def lecun_uniform(tensor, fan_in, **kwargs):
14+
def lecun_uniform(tensor, fan_in):
1515
bound = math.sqrt(3 / fan_in)
1616
tensor.uniform_(-bound, bound)
1717

1818

19-
def zero(tensor, **kwargs):
19+
def zero(tensor):
2020
tensor.fill_(0.0)
2121

2222

23-
def one(tensor, **kwargs):
23+
def one(tensor):
2424
tensor.fill_(1.0)

minitorch/nn/layers.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from ..tensor.functions import rand, zeros
22
from .module import Module, Parameter
3-
from ..backends import fast_conv, fast_ops
3+
from ..backends import fast_conv
44
from . import init
5-
from ..tensor.tensor import Tensor
65

76
try:
87
from ..backends import cuda_conv
@@ -37,24 +36,19 @@ def __init__(self, in_channels, out_channels, kernel_width, backend, stride=1, i
3736
self.kernel_width = kernel_width
3837

3938
def forward(self, input):
40-
# Perform strided convolution manually if stride != 1
4139
batch, in_channels, w = input.shape
4240
kw = self.kernel_width
4341
stride = self.stride
4442
out_channels = self.weights.value.shape[0]
4543

46-
# Calculate output width with stride
4744
out_w = (w - kw) // stride + 1
4845

49-
# Create output tensor
5046
output = input.zeros((batch, out_channels, out_w))
5147

52-
# Perform convolution with stride
5348
for b in range(batch):
5449
for oc in range(out_channels):
5550
for ow in range(out_w):
5651
start_w = ow * stride
57-
# Compute convolution for this window
5852
total = 0.0
5953
for ic in range(in_channels):
6054
for k in range(kw):
@@ -83,7 +77,6 @@ def __init__(self, in_channels, out_channels, kernel, backend, stride=1, initial
8377
self.backend = backend
8478

8579
def forward(self, input):
86-
# Use CUDA conv if backend is CUDA, otherwise use fast conv
8780
if self.backend.cuda and cuda_conv is not None:
8881
out = cuda_conv.conv2d(input, self.weights.value, self.stride) + self.bias.value
8982
else:

minitorch/nn/loss.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from ..tensor import tensor
21
from .nn import logsoftmax
32

43

0 commit comments

Comments
 (0)