| 86 | } |
| 87 | |
| 88 | std::vector<GraphNode*> MultiLabelClassificationTarget( |
| 89 | const std::string& prefix, GraphNode* X, int has_w) { |
| 90 | DXCHECK_THROW(X->shape().is_rank(2)); |
| 91 | auto* X1 = deepx_core::Reshape2("X1", X, Shape(-1, 1)); |
| 92 | auto* Y = deepx_core::GetY(1); |
| 93 | auto* Y1 = deepx_core::Reshape2("Y1", Y, Shape(-1, 1)); |
| 94 | auto* L = deepx_core::SigmoidBCELoss(prefix + "L", X1, Y1); |
| 95 | auto* P = deepx_core::Sigmoid(prefix + "P", X); |
| 96 | if (has_w) { |
| 97 | auto* W = deepx_core::GetW(1); |
| 98 | auto* WL = deepx_core::Mul(prefix + "WL", L, W); |
| 99 | auto* WM = deepx_core::ReduceMean(prefix + "WM", WL); |
| 100 | return {WM, P}; |
| 101 | } else { |
| 102 | auto* M = deepx_core::ReduceMean(prefix + "M", L); |
| 103 | return {M, P}; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | std::vector<GraphNode*> MultiLabelClassificationTarget(GraphNode* X, |
| 108 | int has_w) { |