Skip to content

Classification Visualization plots a transposed image #145

Open
@prateekgargX

Description

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

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions