SNR for both layers
@@ -29,13 +29,13 @@ class NoisyDQN(nn.Module):
conv_out_size = self._get_conv_out(input_shape)
self.noisy_layers = [
-# dqn_model.NoisyLinear(conv_out_size, 512),
+ dqn_model.NoisyLinear(conv_out_size, 512),
dqn_model.NoisyLinear(512, n_actions)
]
self.fc = nn.Sequential(
- nn.Linear(conv_out_size, 512),
+ self.noisy_layers[0],
nn.ReLU(),
- self.noisy_layers[0]
+ self.noisy_layers[1]
)
def _get_conv_out(self, shape):
@@ -47,11 +47,9 @@ class NoisyDQN(nn.Module):
conv_out = self.conv(fx).view(fx.size()[0], -1)
return self.fc(conv_out)
- def noisy_layers_sigma_l2(self):
+ def noisy_layers_sigma_snr(self):
return [
((layer.weight ** 2).mean().sqrt() / (layer.sigma_weight ** 2).mean().sqrt()).data.cpu().numpy()[0]
-# ((layer.weight.abs() - layer.sigma_weight.abs()) / layer.weight.abs()).mean().data.cpu().numpy()[0]
-# (layer.sigma_weight ** 2).sum().sqrt().data.cpu().numpy()[0]
for layer in self.noisy_layers
]
@@ -103,5 +101,5 @@ if __name__ == "__main__":
if frame_idx % 500 == 0:
for layer_idx, sigma_l2 in enumerate(net.noisy_layers_sigma_l2()):
- writer.add_scalar("sigma_l2_layer_%d" % (layer_idx+1),
+ writer.add_scalar("sigma_snr_layer_%d" % (layer_idx+1),
sigma_l2, frame_idx)
