| 53 | } |
| 54 | |
| 55 | std::vector<GraphNode*> MultiClassificationTarget(const std::string& prefix, |
| 56 | GraphNode* X, int has_w) { |
| 57 | DXCHECK_THROW(X->shape().is_rank(2)); |
| 58 | auto* Y = deepx_core::GetY(1); |
| 59 | auto* L = deepx_core::BatchSoftmaxCELoss(prefix + "L", X, Y); |
| 60 | auto* P = deepx_core::Softmax(prefix + "P", X); |
| 61 | if (has_w) { |
| 62 | auto* W = deepx_core::GetW(1); |
| 63 | auto* WL = deepx_core::Mul(prefix + "WL", L, W); |
| 64 | auto* WM = deepx_core::ReduceMean(prefix + "WM", WL); |
| 65 | return {WM, P}; |
| 66 | } else { |
| 67 | auto* M = deepx_core::ReduceMean(prefix + "M", L); |
| 68 | return {M, P}; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | std::vector<GraphNode*> MultiClassificationTarget(GraphNode* X, int has_w) { |
| 73 | DXCHECK_THROW(X->shape().is_rank(2)); |