HiDDeN
HiDDeN copied to clipboard
error ouccur when validating a distortion with its hyperparameters e.g crop
`--------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[1], line 76 73 image = image.to(device) 74 message = torch.Tensor(np.random.choice([0, 1], (image.shape[0], hidden_config.message_length))).to(device) ---> 76 losses, (encoded_images, noised_images, decoded_messages) = model.validate_on_batch([image, message]) 78 # Calculate average bitwise error 79 decoded_rounded = decoded_messages.detach().cpu().numpy().round().clip(0, 1)
File ~/feiyuchen3/HiDDeN-master/model/hidden.py:166, in Hidden.validate_on_batch(self, batch) 163 ###### 164 d_loss_on_cover = self.bce_with_logits_loss(d_on_cover, d_target_label_cover) --> 166 encoded_images, noised_images, decoded_messages = self.encoder_decoder(images, messages) 168 d_on_encoded = self.discriminator(encoded_images) 169 ######
File ~/anaconda3/envs/pytorch_lab20/lib/python3.9/site-packages/torch/nn/modules/module.py:1501, in Module._call_impl(self, *args, **kwargs) 1496 # If we don't have any hooks, we want to skip the rest of the logic in 1497 # this function, and just call forward. 1498 if not (self._backward_hooks or self._backward_pre_hooks or self._forward_hooks or self._forward_pre_hooks 1499 or _global_backward_pre_hooks or _global_backward_hooks 1500 or _global_forward_hooks or _global_forward_pre_hooks): -> 1501 return forward_call(*args, **kwargs) 1502 # Do not call functions when jit is used 1503 full_backward_hooks, non_full_backward_hooks = [], [] ... 30 random_noise_layer = np.random.choice(self.noise_layers, 1)[0] 31 print(random_noise_layer) ---> 32 return random_noise_layer(encoded_and_cover)
TypeError: 'dict' object is not callable`
This is the error log.
After checking, the bug may be the stored trained experiments' configure.
Take the crop-0.2-025 for example. In this situation, the random_noise_layer = np.random.choice(self.noise_layers, 1)[0]
would output a dictionary in the form of {'type': 'crop', 'height_ratios': (0.2, 0.25), 'width_ratios': (0.2, 0.25)}
. Instead, we need here a function