Sampfuncs 037 R5 Upd -
# ---------------------------------------------------------- # 4️⃣ Determine how many samples each stratum contributes per batch # ---------------------------------------------------------- # Compute the proportion of each stratum in the whole dataset. total_n = labels.shape[0] stratum_counts = np.array([len(arr) for arr in strata_to_indices.values()], dtype=np.int64) stratum_proportions = stratum_counts / total_n
# Round to nearest integer while guaranteeing the sum ≤ batch_size. # We use the “largest remainder” method (a.k.a. Hamilton method). floor_counts = np.floor(ideal_per_batch).astype(np.int64) remainder = ideal_per_batch - floor_counts deficit = batch_size - floor_counts.sum() sampfuncs 037 r5
For a step-by-step walkthrough on how to set up the environment for these scripts, you can watch this installation guide: you can watch this installation guide: