mickylan2367 commited on
Commit
12144fd
1 Parent(s): 0516d18

Update README

Browse files
Files changed (1) hide show
  1. README.md +16 -17
README.md CHANGED
@@ -1,11 +1,11 @@
1
  ---
2
- task_categories:
3
- - text-generation
4
  license: cc-by-sa-4.0
5
  language:
6
  - en
7
  tags:
8
  - music
 
 
9
  ---
10
  # Google/Music-Capsの音声データをスペクトログラム化したデータ。
11
 
@@ -26,13 +26,14 @@ data = data["train"]
26
  ```
27
 
28
  ### 1: データローダーへ
29
- * まだテストデータと検証データは用意していないので、コメントアウトしています
30
  * こんな感じの関数で、データローダーにできます。
31
  ```py
32
  from torchvision import transforms
33
  from torch.utils.data import DataLoader
34
  BATCH_SIZE = ??? # 自分で設定
35
  IMAGE_SIZE = ???
 
 
36
 
37
  def load_datasets():
38
  data_transforms = [
@@ -42,26 +43,24 @@ def load_datasets():
42
  ]
43
  data_transform = transforms.Compose(data_transforms)
44
 
45
- train = load_dataset("mickylan2367/spectrogram", split="train")
46
- # test = load_dataset("mickylan2367/spectrogram", split="test")
47
- # validation = load_dataset("mickylan2367/spectrogram", split="validation")
 
48
 
49
  for idx in range(len(train["image"])):
50
  train["image"][idx] = data_transform(train["image"][idx])
51
- # test["image"][idx] = data_transform(test["image"][idx])
52
- # validation["image"][idx] = data_transform(validation["image"][idx])
53
 
54
  train = Dataset.from_dict(train)
55
- # test = Dataset.from_dict(test)
56
- # validation = Dataset.from_dict(validation)
57
-
58
  train = train.with_format("torch") # リスト型回避
59
- # test = test.with_format("torch")
60
- # validation = validation.with_format(validation)
61
-
62
- # dataset = torch.utils.data.ConcatDataset([train, validation, test])
63
- # dataloader = DataLoader(dataset, batch_size=BATCH_SIZE, shuffle=True, drop_last=True)
64
- # return dataloader
 
65
 
66
  ```
67
 
 
1
  ---
 
 
2
  license: cc-by-sa-4.0
3
  language:
4
  - en
5
  tags:
6
  - music
7
+ size_categories:
8
+ - 1K<n<10K
9
  ---
10
  # Google/Music-Capsの音声データをスペクトログラム化したデータ。
11
 
 
26
  ```
27
 
28
  ### 1: データローダーへ
 
29
  * こんな感じの関数で、データローダーにできます。
30
  ```py
31
  from torchvision import transforms
32
  from torch.utils.data import DataLoader
33
  BATCH_SIZE = ??? # 自分で設定
34
  IMAGE_SIZE = ???
35
+ TRAIN_SIZE = ??? # 訓練に使用したいデータセット数
36
+ TEST_SIZE = ??? # テストに使用したいデータセット数
37
 
38
  def load_datasets():
39
  data_transforms = [
 
43
  ]
44
  data_transform = transforms.Compose(data_transforms)
45
 
46
+ data = load_dataset("mickylan2367/spectrogram")
47
+ data = data["train"]
48
+ train = data[slice(0, TRAIN_SIZE, None)]
49
+ test = data[slice(TRAIN_SIZE, TRAIN_SIZE + TEST_SIZE, 0)]
50
 
51
  for idx in range(len(train["image"])):
52
  train["image"][idx] = data_transform(train["image"][idx])
53
+ test["image"][idx] = data_transform(test["image"][idx])
 
54
 
55
  train = Dataset.from_dict(train)
 
 
 
56
  train = train.with_format("torch") # リスト型回避
57
+ test = Dataset.from_dict(train)
58
+ test = test.with_format("torch") # リスト型回避
59
+
60
+ # or
61
+ train_loader = DataLoader(train, batch_size=BATCH_SIZE, shuffle=True, drop_last=True)
62
+ test_loader = DataLoader(test, batch_size=BATCH_SIZE, shuffle=True, drop_last=True)
63
+ return train_loader, test_loader
64
 
65
  ```
66