Skip to content

Commit 2b66fac

Browse files
committed
minor cleanup
1 parent 579dc30 commit 2b66fac

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

questions/123_mixed_precision_training/solution.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
import json
32

43
class MixedPrecision:
54
def __init__(self, loss_scale=1024.0):
@@ -13,7 +12,7 @@ def forward(self, weights, inputs, targets):
1312

1413
# Simple forward pass: linear model + MSE loss
1514
predictions = np.dot(inputs_fp16, weights_fp16)
16-
loss = np.mean((predictions - targets_fp16) ** 2)
15+
loss = np.mean((targets_fp16 - predictions) ** 2)
1716

1817
# Scale loss and convert back to float32 (Python float)
1918
scaled_loss = float(loss) * self.loss_scale

0 commit comments

Comments
 (0)