Load label dict from file Parameters ---------- filename: str filename to load DGLGraphs Returns ---------- labels: dict dict of labels stored in file (empty dict returned if no label stored) Examples ---------- Following the exampl
(filename)
| 220 | |
| 221 | |
| 222 | def load_labels(filename): |
| 223 | """ |
| 224 | Load label dict from file |
| 225 | |
| 226 | Parameters |
| 227 | ---------- |
| 228 | filename: str |
| 229 | filename to load DGLGraphs |
| 230 | |
| 231 | Returns |
| 232 | ---------- |
| 233 | labels: dict |
| 234 | dict of labels stored in file (empty dict returned if no |
| 235 | label stored) |
| 236 | |
| 237 | Examples |
| 238 | ---------- |
| 239 | Following the example in save_graphs. |
| 240 | |
| 241 | >>> from dgl.data.utils import load_labels |
| 242 | >>> label_dict = load_graphs("./data.bin") |
| 243 | |
| 244 | """ |
| 245 | # if it is local file, do some sanity check |
| 246 | check_local_file_exists(filename) |
| 247 | |
| 248 | version = _CAPI_GetFileVersion(filename) |
| 249 | if version == 1: |
| 250 | return load_labels_v1(filename) |
| 251 | elif version == 2: |
| 252 | return load_labels_v2(filename) |
| 253 | else: |
| 254 | raise Exception("Invalid DGL Version Number") |
| 255 | |
| 256 | |
| 257 | def load_labels_v2(filename): |