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

RuntimeError: output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28] #10

Open
bignightcat opened this issue May 12, 2019 · 1 comment

Comments

@bignightcat
Copy link

for x_, _ in train_loader:
    # train discriminator D
    D.zero_grad()

    x_ = x_.view(-1, 28 * 28)

    mini_batch = x_.size()[0]

When I tried to run these lines, it showed me " output with shape [1, 28, 28] doesn't match the broadcast shape [3, 28, 28]" and I don't know why.

Could you help me to fix this bug?

And by the way, in the loop "for x_, _ in train_loader", what is the structure of x_ and ? I could not get the meaning of x and _

I am new to GAN. Thanks!

@gktejus
Copy link

gktejus commented May 15, 2019

@bignightcat
Replace

# data_loader
img_size = 64
transform = transforms.Compose([
        transforms.Scale(img_size),
        transforms.ToTensor(),
        transforms.Normalize(mean=(0.5,0.5,0.5), std=(0.5,0.5,0.5))
])

with

# data_loader
img_size = 64
transform = transforms.Compose([
        transforms.Scale(img_size),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.5], std=[0.5])
])

x_ represents a batch of images and _ represents their respective labels with which we aren't bothered about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants