Skip to content

Bug Report for handwritten-digit-classifier #5121

@vsancnaj

Description

@vsancnaj

Bug Report for https://neetcode.io/problems/handwritten-digit-classifier

Please describe the bug below and include any steps to reproduce the bug or screenshots if possible.

I applied this code and it marked it as wrong answer:

class Solution(nn.Module):

def init(self):

super().init()

torch.manual_seed(0)

# flatten the image to 1d vector

# self.flatten = nn.Flatten()

self.first = nn.Linear((28*28),512)

self.second = nn.ReLU()

self.third = nn.Dropout(p=0.2)

self.fourth = nn.Linear(512,10)

self.final = nn.Sigmoid()

# Define the architecture here

def forward(self, images: TensorType[float]) -> TensorType[float]:

torch.manual_seed(0)

# x = self.flatten(images)

x = self.first(images) # linear projection

x = self.second(x) # ReLU

x = self.third(x) # Dropout

x = self.fourth(x) # logits (shape: batch × 10)

x = self.final(x) # probabilities

return torch.round(x, decimals=4)

# Return the model's prediction to 4 decimal places

But when I commented out and applied the solution it still marked it as wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions