add example
Browse files- ceed.py +1 -1
- example.py +41 -0
ceed.py
CHANGED
@@ -50,7 +50,7 @@ _LICENSE = ""
|
|
50 |
# TODO: Add link to the official dataset URLs here
|
51 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
52 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
53 |
-
_REPO_NC =
|
54 |
_FILES_NC = [
|
55 |
"1987.h5",
|
56 |
"1988.h5",
|
|
|
50 |
# TODO: Add link to the official dataset URLs here
|
51 |
# The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
|
52 |
# This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
|
53 |
+
_REPO_NC = "https://huggingface.co/datasets/AI4EPS/quakeflow_nc/resolve/main/waveform_h5"
|
54 |
_FILES_NC = [
|
55 |
"1987.h5",
|
56 |
"1988.h5",
|
example.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# %%
|
2 |
+
import numpy as np
|
3 |
+
from datasets import load_dataset
|
4 |
+
from torch.utils.data import DataLoader
|
5 |
+
|
6 |
+
# %%
|
7 |
+
ceed = load_dataset(
|
8 |
+
"./ceed.py",
|
9 |
+
name="station_test",
|
10 |
+
# name="event_test",
|
11 |
+
split="test",
|
12 |
+
download_mode="force_redownload",
|
13 |
+
)
|
14 |
+
|
15 |
+
# print the first sample of the iterable dataset
|
16 |
+
for example in ceed:
|
17 |
+
print("\nIterable test\n")
|
18 |
+
print(example.keys())
|
19 |
+
for key in example.keys():
|
20 |
+
if key == "data":
|
21 |
+
print(key, np.array(example[key]).shape)
|
22 |
+
else:
|
23 |
+
print(key, example[key])
|
24 |
+
break
|
25 |
+
|
26 |
+
# %%
|
27 |
+
ceed = ceed.with_format("torch")
|
28 |
+
dataloader = DataLoader(ceed, batch_size=8, num_workers=0, collate_fn=lambda x: x)
|
29 |
+
|
30 |
+
for batch in dataloader:
|
31 |
+
print("\nDataloader test\n")
|
32 |
+
print(f"Batch size: {len(batch)}")
|
33 |
+
print(batch[0].keys())
|
34 |
+
for key in batch[0].keys():
|
35 |
+
if key == "data":
|
36 |
+
print(key, np.array(batch[0][key]).shape)
|
37 |
+
else:
|
38 |
+
print(key, batch[0][key])
|
39 |
+
break
|
40 |
+
|
41 |
+
# %%
|