fix split valid issue
import numpy as np
-from ogb.lsc import MAG240MDataset, MAG240MEvaluator
+from ogb.lsc import MAG240MDataset
+import os
+
+def create_split_dir(source_dir, split_dir):
+ dataset = MAG240MDataset(source_dir)
+ split_dir_exists = os.path.exists(split_dir)
+ if not split_dir_exists:
+ os.mkdir(split_dir)
-def split_dir(data_dir, output_dit):
- dataset = MAG240MDataset(data_dir)
valid_idx = dataset.get_idx_split("valid")
np.random.seed(999)
np.random.shuffle(valid_idx)
- star = 0
end = len(valid_idx)
part = len(valid_idx) // 5 + 1
@@ -14,11 +18,11 @@ def split_dir(data_dir, output_dit):
y = min(x + part, end)
valid_part = valid_idx[x: y]
print(valid_part.shape)
- path_p = f"{output_dit}/valid_{idx}"
- np.save(path_p, valid_part)
+ split_file = f"{split_dir}/valid_{idx}"
+ np.save(split_file, valid_part)
if __name__ == "__main__":
- data_dir = "dataset_path"
- output_dir = 'valid_64'
- split_valid(data_dir, output_dir)
\ No newline at end of file
+ source_data_dir = 'your_source_data_dir'
+ split_data_dir = 'your_split_data_dir'
+ create_split_dir(source_dir=source_data_dir, split_dir=split_data_dir)
