Convert kernel_mask into a constant tensor #74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I use the given implementation for training, I always get NaN values at the output. Sometimes this happens after a few training steps and sometimes after a few epochs (depending on the training data used).
While debugging, I noticed that the
kernel_mask
was updated. I think this is becauseK.ones(shape=...)
returns a trainable variable if all entries in the passed shape are >0. In the original PyTorch implementation thekernel_mask
is initialized usingweight_maskUpdater = torch.ones(...)
, which by default creates a non-trainable tensor (sincerequires_grad=False
).After replacing
K.ones(...)
withK.constant(...)
the NaN values no longer occur.