mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Fixed a bug in the cuDNN binding that on rare occasions caused NaN outputs from
batch normalization. The running mean and variance need to be initialized when calling cuDNN, even if the averaging factor is 1. I don't think this was the case prior to cuDNN v5, but it certainly is the case now. This patch fixes this.
This commit is contained in:
parent
98da589f9d
commit
ceb6a119d5
@ -445,6 +445,14 @@ namespace dlib
|
||||
invstds.copy_size(means);
|
||||
running_means.copy_size(means);
|
||||
running_variances.copy_size(means);
|
||||
// cuDNN requires that running_means and running_variances be initialized to
|
||||
// some valid float values even if the averaging factor would have ignored
|
||||
// them.
|
||||
if (averaging_factor == 1)
|
||||
{
|
||||
running_means = 0;
|
||||
running_variances = 1;
|
||||
}
|
||||
|
||||
CHECK_CUDNN(cudnnBatchNormalizationForwardTraining(
|
||||
context(),
|
||||
@ -627,6 +635,14 @@ namespace dlib
|
||||
invstds.copy_size(means);
|
||||
running_means.copy_size(means);
|
||||
running_variances.copy_size(means);
|
||||
// cuDNN requires that running_means and running_variances be initialized to
|
||||
// some valid float values even if the averaging factor would have ignored
|
||||
// them.
|
||||
if (averaging_factor == 1)
|
||||
{
|
||||
running_means = 0;
|
||||
running_variances = 1;
|
||||
}
|
||||
|
||||
CHECK_CUDNN(cudnnBatchNormalizationForwardTraining(
|
||||
context(),
|
||||
|
Loading…
Reference in New Issue
Block a user