How to average over different/multiple axes of weights matrix? #2402
Answered
by
szaman19
jvwilliams23
asked this question in
Q&A
-
Hi again, I am trying to convert the following from pytorch to LBANN: # w is weights of a 2D convolution layer, shape is [batch, 512, 512, 3, 3]
# x is a featuremap, shape is [batch, 512, 8, 8]
dcoefs = (w.square().sum(dim=[2, 3, 4]) + 1e-8).rsqrt() # [NO]
# dcoefs is essentially a scaling for each output channel, shape is [batch, 512]
x = x * dcoefs.reshape(batch_size, -1, 1, 1) But, I am not sure how to do the ".sum(dim=[2,3,4])" operation. I tried the following:
Any idea how to do this? Regards, |
Beta Was this translation helpful? Give feedback.
Answered by
szaman19
Dec 12, 2023
Replies: 1 comment 4 replies
-
We're working on expanding the
|
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
jvwilliams23
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We're working on expanding the
Reduction
layer but in the meantime, this is the hack I have to do reductions on 3/4D inputs using grouped convolutions with frozen constant weights.