Skip to content

Vectorized fill_up weights and run linter on project#25

Open
developer0hye wants to merge 4 commits intoxingyizhou:masterfrom
developer0hye:patch-1
Open

Vectorized fill_up weights and run linter on project#25
developer0hye wants to merge 4 commits intoxingyizhou:masterfrom
developer0hye:patch-1

Conversation

@developer0hye
Copy link

@developer0hye developer0hye commented Mar 24, 2021

Thanks for your contribution!

If you're sending a large PR (e.g., >100 lines),
please open an issue first about the feature / bug, and indicate how you want to contribute.

We do not always accept features.
See https://detectron2.readthedocs.io/notes/contributing.html#pull-requests about how we handle PRs.

Before submitting a PR, please run dev/linter.sh to lint the code.

Actually, I modified 3 lines in dla.py and dla_fpn.py. However, many lines are modified after linter...

Before

def fill_up_weights(up):
w = up.weight.data
f = math.ceil(w.size(2) / 2)
c = (2 * f - 1 - f % 2) / (2. * f)
for i in range(w.size(2)):
for j in range(w.size(3)):
w[0, 0, i, j] = \
(1 - math.fabs(i / f - c)) * (1 - math.fabs(j / f - c))
for c in range(1, w.size(0)):
w[c, 0, :, :] = w[0, 0, :, :]

After

def fill_up_weights(up):
w = up.weight.data
f = math.ceil(w.size(2) / 2)
c = (2 * f - 1 - f % 2) / (2.0 * f)
for i in range(w.size(2)):
for j in range(w.size(3)):
w[:, 0, i, j] = (1 - math.fabs(i / f - c)) * (1 - math.fabs(j / f - c))

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

Successfully merging this pull request may close these issues.

1 participant