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: The size of tensor a (784) must match the size of tensor b (28) at non-singleton dimension 3 #2

Open
aduk4u opened this issue Apr 2, 2020 · 0 comments

Comments

@aduk4u
Copy link

aduk4u commented Apr 2, 2020


RuntimeError Traceback (most recent call last)
in
28 engine.hooks['on_end_epoch'] = on_end_epoch
29
---> 30 engine.train(processor, get_iterator(True), maxepoch=NUM_EPOCHS, optimizer=optimizer)

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torchnet\engine\engine.py in train(self, network, iterator, maxepoch, optimizer)
61
62 state['optimizer'].zero_grad()
---> 63 state['optimizer'].step(closure)
64 self.hook('on_update', state)
65 state['t'] += 1

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\optim\adam.py in step(self, closure)
56 loss = None
57 if closure is not None:
---> 58 loss = closure()
59
60 for group in self.param_groups:

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torchnet\engine\engine.py in closure()
50
51 def closure():
---> 52 loss, output = state'network'
53 state['output'] = output
54 state['loss'] = loss

in processor(sample)
16 classes, reconstructions = model(data)
17
---> 18 loss = capsule_loss(data, labels, classes, reconstructions)
19 return loss, classes
20

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
--> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

in forward(self, images, labels, classes, reconstrunctions)
14 #images = images.view(reconstructions.size()[0], -1)
15
---> 16 reconstrunction_loss = self.reconstrunction_loss(reconstrunctions, images)
17
18 return (margin_loss + 0.0005 * reconstrunction_loss) / images.size(0)

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\nn\modules\module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
--> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\nn\modules\loss.py in forward(self, input, target)
429
430 def forward(self, input, target):
--> 431 return F.mse_loss(input, target, reduction=self.reduction)
432
433

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\nn\functional.py in mse_loss(input, target, size_average, reduce, reduction)
2213 ret = torch.mean(ret) if reduction == 'mean' else torch.sum(ret)
2214 else:
-> 2215 expanded_input, expanded_target = torch.broadcast_tensors(input, target)
2216 ret = torch._C._nn.mse_loss(expanded_input, expanded_target, _Reduction.get_enum(reduction))
2217 return ret

E:\DeepLearning\envs\tensorflow_gpuenv\lib\site-packages\torch\functional.py in broadcast_tensors(*tensors)
50 [0, 1, 2]])
51 """
---> 52 return torch._C._VariableFunctions.broadcast_tensors(tensors)
53
54

RuntimeError: The size of tensor a (784) must match the size of tensor b (28) at non-singleton dimension 3

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

1 participant