Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Classification Visualization plots a transposed image #145

Open
prateekgargX opened this issue Jun 15, 2024 · 0 comments
Open

Classification Visualization plots a transposed image #145

prateekgargX opened this issue Jun 15, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@prateekgargX
Copy link

prateekgargX commented Jun 15, 2024

Tutorial: 2
Introduction to PyTorch

Bug Description
the function to visualize classification boundary, visualize_classification(model, data, label) plots a transposed image. To fix this, meshgrid indexing has to be changed from 'ij' to 'xy'

To Reproduce
Run the notebook on a dataset which is not symmetric in x1 and x2. For example moons dataset on sklearn.

    def generate_continuous_xor(self):

        X,y = make_moons(n_samples=self.size,random_state=42)
        X = np.float32(X)
        y = np.float32(y)
        mean = np.mean(X, axis=0)
        std = np.std(X, axis=0)
        X = (X - mean) / std

        data = torch.from_numpy(X) #torch.randint(low=0, high=2, size=(self.size, 2), dtype=torch.float32)
        label = torch.from_numpy(y).to(torch.long)
        # To make it slightly more challenging, we add a bit of gaussian noise to the data points.
        data += self.std * torch.randn(data.shape)

        self.data = data
        self.label = label

Screenshots
Earlier:
image

New:
image

Runtime environment:

  • Local computer and Google Colab
  • both on CPU only or GPU

This hasn't been noticed till now since original dataset was symmetric in x1 and x2

@prateekgargX prateekgargX added the bug Something isn't working label Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants