Softmax Regression Prediction
HardMachine LearningMathMatrix
Description
Given a weight matrix W (one row of weights per class), a bias vector b (one bias per class), and a feature vector x, return the predicted class index: the class whose score (dot product of its weight row with x, plus its bias) is largest. Break ties toward the smaller index.
Examples
Input:
[[1,0],[0,1]], [0,0], [2,1]Output:
0Explanation:
Each class produces a score from its own weights and bias, and the class with the highest score becomes the prediction.
Input:
[[1,1],[2,2]], [0,0], [1,1]Output:
1Explanation:
Each class produces a score from its own weights and bias, and the class with the highest score becomes the prediction.
Input:
[[1,0,0],[0,1,0],[0,0,1]], [0,0,0], [3,1,2]Output:
0Explanation:
Each class produces a score from its own weights and bias, and the class with the highest score becomes the prediction.
Constraints
- •
1 ≤ classes ≤ 10³ - •
each weight row length equals x length