We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eb8e14c commit ad91bfeCopy full SHA for ad91bfe
python/paddle/fluid/tests/unittests/test_batch_norm_op.py
@@ -100,6 +100,9 @@ def _reference_grad(x, y_grad, scale, mean, var, epsilon, data_format):
100
# (x - mean) * sum(grad_y * (x - mean)) / (var + epsilon))
101
102
# transfer from (N, C, H, W) to (N, H, W, C) to simplify computation
103
+ if data_format != "NCHW" and data_format != "NHWC":
104
+ raise ValueError("Unknown data order.")
105
+
106
if data_format == "NCHW":
107
x = np.transpose(x, (0, 2, 3, 1))
108
y_grad = np.transpose(y_grad, (0, 2, 3, 1))
@@ -304,7 +307,7 @@ def test_with_place(place, data_layout, shape):
304
307
# run backward
305
308
y_grad = np.random.random_sample(shape).astype(np.float32)
306
309
x_grad, scale_grad, bias_grad = _reference_grad(
- x, y_grad, scale, saved_mean, var_ref, epsilon, data_format)
310
+ x, y_grad, scale, saved_mean, var_ref, epsilon, data_layout)
311
312
var_dict = locals()
313
var_dict['y@GRAD'] = y_grad
0 commit comments