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: input and target shapes do not match: input [2 x 17 x 6 x 9], target [2 x 17] at /pytorch/aten/src/THCUNN/generic/MSECriterion.cu:12 #33

Closed
BugTan opened this issue Sep 4, 2018 · 3 comments

Comments

@BugTan
Copy link

BugTan commented Sep 4, 2018

/usr/bin/python3.6 /home/bugtan/code/GANimation/train.py --data_dir /home/bugtan/code/GANimation/ck_dataset --name experiment_ck --batch_size 2
------------ Options -------------
D_adam_b1: 0.5
D_adam_b2: 0.999
G_adam_b1: 0.5
G_adam_b2: 0.999
aus_file: aus_openface.pkl
batch_size: 2
checkpoints_dir: ./checkpoints
cond_nc: 17
data_dir: /home/bugtan/code/GANimation/ck_dataset
dataset_mode: aus
display_freq_s: 300
do_saturate_mask: False
gpu_ids: [0]
image_size: 128
images_folder: imgs
is_train: True
lambda_D_cond: 4000
lambda_D_gp: 10
lambda_D_prob: 1
lambda_cyc: 10
lambda_mask: 0.1
lambda_mask_smooth: 1e-05
load_epoch: 0
lr_D: 0.0001
lr_G: 0.0001
model: ganimation
n_threads_test: 1
n_threads_train: 4
name: experiment_ck
nepochs_decay: 10
nepochs_no_decay: 20
num_iters_validate: 1
poses_g_sigma: 0.06
print_freq_s: 60
save_latest_freq_s: 3600
serial_batches: False
test_ids_file: test_ids.csv
train_G_every_n_iterations: 5
train_ids_file: train_ids.csv
-------------- End ----------------
./checkpoints/experiment_ck
Dataset AusDataset was created
Dataset AusDataset was created
#train images = 8791
#test images = 4
Network generator_wasserstein_gan was created
Network discriminator_wasserstein_gan was created
Model GANimation was created
Exception ignored in: <bound method _DataLoaderIter.del of <torch.utils.data.dataloader._DataLoaderIter object at 0x7f8e651aea90>>
Traceback (most recent call last):
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 399, in del
self._shutdown_workers()
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 378, in _shutdown_workers
self.worker_result_queue.get()
File "/usr/lib/python3.6/multiprocessing/queues.py", line 337, in get
return _ForkingPickler.loads(res)
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/multiprocessing/reductions.py", line 151, in rebuild_storage_fd
fd = df.detach()
File "/usr/lib/python3.6/multiprocessing/resource_sharer.py", line 58, in detach
return reduction.recv_handle(conn)
File "/usr/lib/python3.6/multiprocessing/reduction.py", line 182, in recv_handle
return recvfds(s, 1)[0]
File "/usr/lib/python3.6/multiprocessing/reduction.py", line 153, in recvfds
msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_LEN(bytes_size))
ConnectionResetError: [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "/home/bugtan/code/GANimation/train.py", line 141, in
Train()
File "/home/bugtan/code/GANimation/train.py", line 27, in init
self._train()
File "/home/bugtan/code/GANimation/train.py", line 40, in _train
self._train_epoch(i_epoch)
File "/home/bugtan/code/GANimation/train.py", line 69, in _train_epoch
self._model.optimize_parameters(keep_data_for_visuals=do_visuals, train_generator=train_generator)
File "/home/bugtan/code/GANimation/models/ganimation.py", line 207, in optimize_parameters
loss_D, fake_imgs_masked = self._forward_D()
File "/home/bugtan/code/GANimation/models/ganimation.py", line 280, in _forward_D
self._loss_d_cond = self._criterion_D_cond(d_real_img_cond, self._real_cond) / self._B * self._opt.lambda_D_cond
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/nn/modules/loss.py", line 421, in forward
return F.mse_loss(input, target, reduction=self.reduction)
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/nn/functional.py", line 1716, in mse_loss
return _pointwise_loss(lambda a, b: (a - b) ** 2, torch._C._nn.mse_loss, input, target, reduction)
File "/home/bugtan/.local/lib/python3.6/site-packages/torch/nn/functional.py", line 1674, in _pointwise_loss
return lambd_optimized(input, target, reduction)
RuntimeError: input and target shapes do not match: input [2 x 17 x 6 x 9], target [2 x 17] at /pytorch/aten/src/THCUNN/generic/MSECriterion.cu:12

Anyone can help me solve this question?

@Blade6570
Copy link

Resize the training images to 128x128x3

@joyyang1997
Copy link

@Blade6570 Shall I do resize before I extract AU?

@Blade6570
Copy link

@joyyang1997 no need. extract AU and then resize it to 128x128. hope it helps.

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

4 participants