Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

the drop_size cannot be higher than 5? #20

Closed
PanXiebit opened this issue Dec 16, 2018 · 7 comments
Closed

the drop_size cannot be higher than 5? #20

PanXiebit opened this issue Dec 16, 2018 · 7 comments

Comments

@PanXiebit
Copy link

PanXiebit commented Dec 16, 2018

padding=int(np.ceil(self.block_size // 2) + 1))

the implement of computer block mask using conv1d is to handle with the overlapped? and the output of _computer_block_mask must have the same size with x, right?

but when I try block_size=7, the output of block_block_mask is [N, 1, 1]. and when I try block_size=9, I will get an error.

In the function of computer block mask, after conv2d, the size of height and weight is
mask_size + 2*(block_size//2+1) - block_size + 1,
the height and weight of input x is mask_size + block_size//2.
and the former must be larger than the latter, so the (block_size//2) connot higher than 3?

@miguelvr
Copy link
Owner

The block size can be bigger for sure. It is being tested in the unit tests.

What is the shape of your input?

@miguelvr miguelvr reopened this Dec 16, 2018
@PanXiebit
Copy link
Author

@miguelvr I test like this

x = torch.rand(100, 10, 16, 16)
drop_block = DropBlock2D(block_size=9, drop_prob=0.3)

and get the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/panxie/.conda/envs/NLP/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/panxie/.conda/envs/NLP/lib/python3.6/site-packages/dropblock/dropblock.py", line 67, in forward
    out = x * block_mask[:, None, :, :]
RuntimeError: The size of tensor a (16) must match the size of tensor b (2) at non-singleton dimension 3

@miguelvr
Copy link
Owner

That input is too small for a 9x9 block. The Bernoulli mask is going to be computed on a subset of your input of shape (W - bsize // 2, H - bsize // 2)

@PanXiebit
Copy link
Author

>>> x = torch.rand(100, 10, 64, 64)
>>> drop_block = DropBlock2D(block_size=9, drop_prob=0.3)
>>> regularized_x = drop_block(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/panxie/.conda/envs/NLP/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/panxie/.conda/envs/NLP/lib/python3.6/site-packages/dropblock/dropblock.py", line 67, in forward
    out = x * block_mask[:, None, :, :]
RuntimeError: The size of tensor a (64) must match the size of tensor b (2) at non-singleton dimension 3

I try bigger size input, still get the error.
I think the problem is the padding is to small, if padding=int(2 * np.ceil(self.block_size//2)) no matter how bigger block_size, the height_to_crop can be positive.

@miguelvr miguelvr reopened this Dec 16, 2018
@miguelvr
Copy link
Owner

Are you using the last version? I'll check that tomorrow

@miguelvr
Copy link
Owner

Please use the bleeding edge version from github now, it should be fixed in #21

I'll do a version bump soon and upload to pypi, in order to install from pip

@miguelvr
Copy link
Owner

should be now in pypi

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

No branches or pull requests

2 participants