Convert expert indices to multi-label binary targets.
(expert_indices, num_experts)
| 271 | |
| 272 | |
| 273 | def build_target_multilabel(expert_indices, num_experts): |
| 274 | """Convert expert indices to multi-label binary targets.""" |
| 275 | N = len(expert_indices) |
| 276 | targets = np.zeros((N, num_experts), dtype=np.float32) |
| 277 | for i in range(N): |
| 278 | for j in range(expert_indices.shape[1]): |
| 279 | e = expert_indices[i, j] |
| 280 | if e >= 0: # skip -1 padding (0 is a valid expert index) |
| 281 | targets[i, e] = 1.0 |
| 282 | return targets |
| 283 | |
| 284 | |
| 285 | def build_cross_layer_pairs(layers, hiddens, experts, num_layers): |
no outgoing calls
no test coverage detected