MCPcopy Index your code
hub / github.com/TorchSSL/TorchSSL / split_ssl_data

Function split_ssl_data

datasets/data_utils.py:14–28  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

12
13
14def 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
31def sample_labeled_data(args, data, target,

Callers 1

get_ssl_dsetMethod · 0.85

Calls 1

sample_labeled_dataFunction · 0.85

Tested by

no test coverage detected