yangwang825 commited on
Commit
9debce6
1 Parent(s): 03acc70

Create configuration_xvector.py

Browse files
Files changed (1) hide show
  1. configuration_xvector.py +58 -0
configuration_xvector.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers.configuration_utils import PretrainedConfig
2
+
3
+
4
+ class XvectorConfig(PretrainedConfig):
5
+
6
+ model_type = 'xvector'
7
+
8
+ def __init__(
9
+ self,
10
+ n_mels=40,
11
+ sample_rate=16000,
12
+ win_length=25,
13
+ hop_length=10,
14
+ mean_norm=True,
15
+ std_norm=False,
16
+ norm_type='sentence',
17
+ tdnn_blocks=5,
18
+ tdnn_channels=[512, 512, 512, 512, 1500],
19
+ tdnn_kernel_sizes=[5, 3, 3, 1, 1],
20
+ tdnn_dilations=[1, 2, 3, 1, 1],
21
+ hidden_size=512,
22
+ num_classes=1251,
23
+ loss_fn='aam',
24
+ auto_map={
25
+ "AutoConfig": "configuration_xvector.XvectorConfig",
26
+ "AutoModel": "modeling_xvector.XvectorModel",
27
+ "AutoModelForAudioClassification": "modeling_xvector.XvectorModelForSequenceClassification"
28
+ },
29
+ initializer_range=0.02,
30
+ **kwargs
31
+ ):
32
+ # Compute features
33
+ self.n_mels = n_mels
34
+ self.sample_rate = sample_rate
35
+ self.win_length = win_length
36
+ self.hop_length = hop_length
37
+
38
+ # Mean variance norm
39
+ self.mean_norm = mean_norm
40
+ self.std_norm = std_norm
41
+ self.norm_type = norm_type
42
+
43
+ # Embedding model
44
+ self.tdnn_blocks = tdnn_blocks
45
+ self.tdnn_channels = tdnn_channels
46
+ self.tdnn_kernel_sizes = tdnn_kernel_sizes
47
+ self.tdnn_dilations = tdnn_dilations
48
+ self.hidden_size = hidden_size
49
+
50
+ # Classifier
51
+ self.num_classes = num_classes
52
+ self.loss_fn = loss_fn
53
+
54
+ # Others
55
+ self.auto_map = auto_map
56
+ self.initializer_range = initializer_range
57
+
58
+ super().__init__(**kwargs)