From the substantive-disparity survey. LogisticRegression/digits shows intercepts_max_relative_diff = 0.508 and coef_row_l2_norms_max_relative_diff = 0.0125 even though accuracy matches sklearn within 3e-3 and #434 matched the objective.
Softmax is invariant to adding a constant vector to all class scores: (W, b) and (W + c·1ᵀ, b + d) produce identical probabilities. The parameters are only identified up to that shift. sklearn's multinomial fit centres coefficients and intercepts to sum to zero across classes; Flow reports the raw optimum its LBFGS landed on.
So the reported state difference is (at least partly) a parameterization artifact, not a model difference. Fix: centre Flow's multinomial coefficients and intercepts (subtract the class-mean from each feature column and from the intercept vector) at the end of lin433_multinomial_fit. Predictions and probabilities are mathematically invariant — verify bit-level effect on canonical rows and report; if predictions move in the last ulp from the arithmetic, report exactly which records.
iris shows the same pattern smaller (intercepts_max_relative_diff 0.0009).
From the substantive-disparity survey. LogisticRegression/digits shows
intercepts_max_relative_diff = 0.508andcoef_row_l2_norms_max_relative_diff = 0.0125even though accuracy matches sklearn within 3e-3 and #434 matched the objective.Softmax is invariant to adding a constant vector to all class scores:
(W, b)and(W + c·1ᵀ, b + d)produce identical probabilities. The parameters are only identified up to that shift. sklearn's multinomial fit centres coefficients and intercepts to sum to zero across classes; Flow reports the raw optimum its LBFGS landed on.So the reported state difference is (at least partly) a parameterization artifact, not a model difference. Fix: centre Flow's multinomial coefficients and intercepts (subtract the class-mean from each feature column and from the intercept vector) at the end of
lin433_multinomial_fit. Predictions and probabilities are mathematically invariant — verify bit-level effect on canonical rows and report; if predictions move in the last ulp from the arithmetic, report exactly which records.iris shows the same pattern smaller (
intercepts_max_relative_diff 0.0009).