RuntimeError for LearnedMixin on MNIST
See original GitHub issueIssue Description
Hello, I’m trying to run your LearnedMixin implementation on MNIST but I’m getting the following error:
[2021-07-03 06:58:30] start training
Traceback (most recent call last):
File "main_biased_mnist.py", line 138, in <module>
fire.Fire(main)
File "/home/barbano/.pyenv/versions/rebias/lib/python3.7/site-packages/fire/core.py", line 141, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/barbano/.pyenv/versions/rebias/lib/python3.7/site-packages/fire/core.py", line 471, in _Fire
target=component.__name__)
File "/home/barbano/.pyenv/versions/rebias/lib/python3.7/site-packages/fire/core.py", line 681, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "main_biased_mnist.py", line 134, in main
save_dir=save_dir)
File "/home/barbano/rebias/trainer.py", line 390, in train
self._train_epoch(tr_loader, cur_epoch)
File "/home/barbano/rebias/trainer.py", line 362, in _train_epoch
self._update_f(x, labels, loss_dict=loss_dict, prefix='train__')
File "/home/barbano/rebias/trainer.py", line 340, in _update_f
_f_loss_indep = self.outer_criterion(f_feats, _g_feats, labels=labels, f_pred=preds)
File "/home/barbano/.pyenv/versions/rebias/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in __call__
result = self.forward(*input, **kwargs)
File "/home/barbano/rebias/criterions/comparison_methods.py", line 92, in forward
loss = F.cross_entropy(f_pred+g_pred, labels)
RuntimeError: The size of tensor a (10) must match the size of tensor b (128) at non-singleton dimension 1
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
AttributeError when selecting 0s and 1s from MNIST dataset ...
I am following a guide to build a model to classify between only 0s and 1s from the MNIST dataset. However, what they...
Read more >arXiv:1909.03683v1 [cs.CL] 9 Sep 2019
In practice, we ignore the p(c) factor because, on our datasets, either the classes are uniformly distributed (MNLI), the bias-only model cannot.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@carloalbertobarbano This issue is resolved by #10 I tested that ReBias works well by the following command
I have confirmed that ReBias unbiased accuracy is 90.11% with AdamP at rho=0.99, where my previous result was 89.60% (average over three different runs)
If you have any other questions, please don’t hesitate to bother me
@carloalbertobarbano I just found that the interface of
outer_criterion
is wrong. https://github.com/clovaai/rebias/blob/master/trainer.py#L338-L341Learned Mixin + H does not use features, but only predictions. I have to update
outer_criterion
interface to getg_pred
as an argument. I will revise this in a few days.Until then, please change the code.
as
for LearnedMixin + H.
It is very strange because all arguments and all numbers are verified before I release the code. Sorry for the inconvenience, and thanks for reporting the bug