Hi, I am currently working on latent space data of Aurora for interpretability research at LMU. I found that spatial plots of latent states of encoding stage 1 strongly resemble those of decoding stage 3, which I didn't expect.
I checked the forward method of Swin3DTransformerBackbone in swin3d.py (
|
skips = [] |
|
# Saved contexts at higher resolutions to be reused in the backbone U-Net decoder |
|
saved_cs = [] |
|
for i, layer in enumerate(self.encoder_layers): |
|
saved_cs.append(c) |
|
x, x_unscaled = layer(x, c, all_enc_res[i], rollout_step=rollout_step) |
|
# There should be a `context_down_layer` for every encoder layer except the last. |
|
if self.stochastic and i < self.num_encoder_layers - 1: |
|
c = self.context_down_layers[i](c, all_enc_res[i]) |
|
skips.append(x_unscaled) |
|
for i, layer in enumerate(self.decoder_layers): |
|
index = self.num_decoder_layers - i - 1 |
|
x, _ = layer( |
|
x, |
|
c, |
|
all_enc_res[index], |
|
padded_outs[index - 1], |
|
rollout_step=rollout_step, |
|
) |
|
|
|
if 0 < i < self.num_decoder_layers - 1: |
|
# For the intermediate stages, we use additive skip connections. |
|
x = x + skips[index - 1] |
|
elif i == self.num_decoder_layers - 1: |
|
# For the last stage, we perform concatentation like in Pangu. |
|
x = torch.cat([x, skips[0]], dim=-1) |
|
|
|
if self.stochastic: |
|
c = saved_cs[index - 1] |
|
return x |
) and to me it seems the skip connections are different than shown in the backbone figure of the paper. I am running version v1.8.0, in which this decoder loop logic is the same as shown here.
Tracing the decoder loop (for i, layer in enumerate(self.decoder_layers), index = self.num_decoder_layers - i - 1):
i=0 (index=2): No skip connection is applied at all. The 0 < i condition in the additive-skip check excludes this case, and i == num_decoder_layers - 1 doesn't match either.
i=1 (index=1): skips[0] (output of encoding stage 1) is added additively to the input of decoding stage 3.
i=2 (index=0): skips[0] is concatenated again to the output of decoding stage 3.
So skips[0] is used twice: once additively before decoding stage 3, and once via concatenation after decoding stage 3. Meanwhile skips[1] (encoding stage 2's output) is not used at all.
Is this intentional, or should skips[1] be used somewhere in the decoder as well? I might be misreading the loop, so let me know if I'm missing something.
Hi, I am currently working on latent space data of Aurora for interpretability research at LMU. I found that spatial plots of latent states of encoding stage 1 strongly resemble those of decoding stage 3, which I didn't expect.
I checked the
forwardmethod ofSwin3DTransformerBackboneinswin3d.py(aurora/aurora/model/swin3d.py
Lines 1026 to 1055 in 639b4e8
Tracing the decoder loop (
for i, layer in enumerate(self.decoder_layers),index = self.num_decoder_layers - i - 1):i=0(index=2): No skip connection is applied at all. The0 < icondition in the additive-skip check excludes this case, andi == num_decoder_layers - 1doesn't match either.i=1(index=1):skips[0](output of encoding stage 1) is added additively to the input of decoding stage 3.i=2(index=0):skips[0]is concatenated again to the output of decoding stage 3.So
skips[0]is used twice: once additively before decoding stage 3, and once via concatenation after decoding stage 3. Meanwhileskips[1](encoding stage 2's output) is not used at all.Is this intentional, or should
skips[1]be used somewhere in the decoder as well? I might be misreading the loop, so let me know if I'm missing something.