HoneyTian commited on
Commit
ab39b36
·
1 Parent(s): 7b2b795
examples/vm_sound_classification/conv2d_classifier.yaml CHANGED
@@ -18,21 +18,21 @@ spec_augment_param:
18
  conv2d_block_param_list:
19
  - batch_norm: true
20
  in_channels: 1
21
- out_channels: 16
22
  kernel_size: 3
23
  stride: 1
24
  dilation: 3
25
  activation: relu
26
  dropout: 0.1
27
- - in_channels: 16
28
- out_channels: 16
29
  kernel_size: 5
30
  stride: 2
31
  dilation: 3
32
  activation: relu
33
  dropout: 0.1
34
- - in_channels: 16
35
- out_channels: 16
36
  kernel_size: 3
37
  stride: 1
38
  dilation: 2
@@ -40,11 +40,11 @@ conv2d_block_param_list:
40
  dropout: 0.1
41
 
42
  cls_head_param:
43
- input_dim: 432
44
  num_layers: 2
45
  hidden_dims:
46
  - 128
47
  - 32
48
  activations: relu
49
  dropout: 0.1
50
- num_labels: 4
 
18
  conv2d_block_param_list:
19
  - batch_norm: true
20
  in_channels: 1
21
+ out_channels: 32
22
  kernel_size: 3
23
  stride: 1
24
  dilation: 3
25
  activation: relu
26
  dropout: 0.1
27
+ - in_channels: 32
28
+ out_channels: 32
29
  kernel_size: 5
30
  stride: 2
31
  dilation: 3
32
  activation: relu
33
  dropout: 0.1
34
+ - in_channels: 32
35
+ out_channels: 32
36
  kernel_size: 3
37
  stride: 1
38
  dilation: 2
 
40
  dropout: 0.1
41
 
42
  cls_head_param:
43
+ input_dim: 864
44
  num_layers: 2
45
  hidden_dims:
46
  - 128
47
  - 32
48
  activations: relu
49
  dropout: 0.1
50
+ num_labels: 2
examples/vm_sound_classification/run.sh CHANGED
@@ -2,22 +2,16 @@
2
 
3
  : <<'END'
4
 
5
- sh run.sh --stage 0 --stop_stage 1 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification4-ch16 \
6
  --filename_patterns "E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/wav_finished/en-US/wav_finished/*/*.wav \
7
  E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/id-ID/wav_finished/*/*.wav" \
8
  --label_plan 4
9
 
10
- sh run.sh --stage 2 --stop_stage 2 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification4-ch16 \
11
  --filename_patterns "E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/wav_finished/en-US/wav_finished/*/*.wav \
12
  E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/id-ID/wav_finished/*/*.wav" \
13
  --label_plan 4
14
 
15
- sh run.sh --stage 2 --stop_stage 2 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification3 --label_plan 4
16
- sh run.sh --stage 3 --stop_stage 3 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification3 --label_plan 4
17
-
18
- sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification4-ch16 \
19
- --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/*/wav_finished/*/*.wav" --label_plan 4
20
-
21
  sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification2-ch32 \
22
  --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/*/wav_finished/*/*.wav" --label_plan 2
23
 
 
2
 
3
  : <<'END'
4
 
5
+ sh run.sh --stage 0 --stop_stage 1 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification4-ch32 \
6
  --filename_patterns "E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/wav_finished/en-US/wav_finished/*/*.wav \
7
  E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/id-ID/wav_finished/*/*.wav" \
8
  --label_plan 4
9
 
10
+ sh run.sh --stage 2 --stop_stage 2 --system_version windows --file_folder_name file_dir --final_model_name vm_sound_classification2-ch32 \
11
  --filename_patterns "E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/wav_finished/en-US/wav_finished/*/*.wav \
12
  E:/Users/tianx/HuggingDatasets/vm_sound_classification/data/wav_finished/id-ID/wav_finished/*/*.wav" \
13
  --label_plan 4
14
 
 
 
 
 
 
 
15
  sh run.sh --stage 0 --stop_stage 5 --system_version centos --file_folder_name file_dir --final_model_name vm_sound_classification2-ch32 \
16
  --filename_patterns "/data/tianxing/PycharmProjects/datasets/voicemail/*/wav_finished/*/*.wav" --label_plan 2
17
 
toolbox/torchaudio/models/cnn_audio_classifier/modeling_cnn_audio_classifier.py CHANGED
@@ -273,6 +273,12 @@ class WaveEncoder(nn.Module):
273
  conv2d_block_param_list=conv2d_block_param_list,
274
  )
275
 
 
 
 
 
 
 
276
  def forward(self, inputs: torch.Tensor):
277
  # x: [batch_size, spec_dim, seq_length]
278
  x = inputs
@@ -283,8 +289,7 @@ class WaveEncoder(nn.Module):
283
  x = x.log()
284
  x = x - torch.mean(x, dim=-1, keepdim=True)
285
 
286
- if self.training:
287
- x = self.spec_augment.forward(x)
288
 
289
  x = x.transpose(1, 2)
290
 
 
273
  conv2d_block_param_list=conv2d_block_param_list,
274
  )
275
 
276
+ @torch.jit.ignore
277
+ def do_spec_augment(self, spec: torch.Tensor) -> torch.Tensor:
278
+ if self.training:
279
+ spec = self.spec_augment.forward(spec)
280
+ return spec
281
+
282
  def forward(self, inputs: torch.Tensor):
283
  # x: [batch_size, spec_dim, seq_length]
284
  x = inputs
 
289
  x = x.log()
290
  x = x - torch.mean(x, dim=-1, keepdim=True)
291
 
292
+ x = self.do_spec_augment(x)
 
293
 
294
  x = x.transpose(1, 2)
295