data & target is splitted into labeled and unlabeld data. Args index: If np.array of index is given, select the data[index], target[index] as labeled samples. include_lb_to_ulb: If True, labeled data is also included in unlabeld data
(args, data, target, num_labels, num_classes, index=None, include_lb_to_ulb=True)
| 12 | |
| 13 | |
| 14 | def split_ssl_data(args, data, target, num_labels, num_classes, index=None, include_lb_to_ulb=True): |
| 15 | """ |
| 16 | data & target is splitted into labeled and unlabeld data. |
| 17 | |
| 18 | Args |
| 19 | index: If np.array of index is given, select the data[index], target[index] as labeled samples. |
| 20 | include_lb_to_ulb: If True, labeled data is also included in unlabeld data |
| 21 | """ |
| 22 | data, target = np.array(data), np.array(target) |
| 23 | lb_data, lbs, lb_idx, = sample_labeled_data(args, data, target, num_labels, num_classes, index) |
| 24 | ulb_idx = np.array(sorted(list(set(range(len(data))) - set(lb_idx)))) # unlabeled_data index of data |
| 25 | if include_lb_to_ulb: |
| 26 | return lb_data, lbs, data, target |
| 27 | else: |
| 28 | return lb_data, lbs, data[ulb_idx], target[ulb_idx] |
| 29 | |
| 30 | |
| 31 | def sample_labeled_data(args, data, target, |
no test coverage detected