yangwang825
commited on
Upload model
Browse files- config.json +5 -3
- modeling_wav2vec2_spkreg.py +5 -2
config.json
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
{
|
|
|
2 |
"activation_dropout": 0.0,
|
3 |
"adapter_attn_dim": null,
|
4 |
"adapter_kernel_size": 3,
|
@@ -6,11 +7,12 @@
|
|
6 |
"add_adapter": false,
|
7 |
"apply_spec_augment": true,
|
8 |
"architectures": [
|
9 |
-
"
|
10 |
],
|
11 |
"attention_dropout": 0.1,
|
12 |
"auto_map": {
|
13 |
-
"AutoConfig": "configuration_wav2vec2_spkreg.Wav2Vec2SpkRegConfig"
|
|
|
14 |
},
|
15 |
"bos_token_id": 1,
|
16 |
"classifier_proj_size": 256,
|
@@ -56,7 +58,6 @@
|
|
56 |
"feat_quantizer_dropout": 0.0,
|
57 |
"final_dropout": 0.0,
|
58 |
"freeze_feat_extract_train": true,
|
59 |
-
"gradient_checkpointing": true,
|
60 |
"hidden_act": "gelu",
|
61 |
"hidden_dropout": 0.1,
|
62 |
"hidden_size": 768,
|
@@ -119,6 +120,7 @@
|
|
119 |
1,
|
120 |
1
|
121 |
],
|
|
|
122 |
"transformers_version": "4.46.2",
|
123 |
"use_weighted_layer_sum": false,
|
124 |
"vocab_size": 32,
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "facebook/wav2vec2-base",
|
3 |
"activation_dropout": 0.0,
|
4 |
"adapter_attn_dim": null,
|
5 |
"adapter_kernel_size": 3,
|
|
|
7 |
"add_adapter": false,
|
8 |
"apply_spec_augment": true,
|
9 |
"architectures": [
|
10 |
+
"Wav2Vec2SpkRegModel"
|
11 |
],
|
12 |
"attention_dropout": 0.1,
|
13 |
"auto_map": {
|
14 |
+
"AutoConfig": "configuration_wav2vec2_spkreg.Wav2Vec2SpkRegConfig",
|
15 |
+
"AutoModel": "modeling_wav2vec2_spkreg.Wav2Vec2SpkRegModel"
|
16 |
},
|
17 |
"bos_token_id": 1,
|
18 |
"classifier_proj_size": 256,
|
|
|
58 |
"feat_quantizer_dropout": 0.0,
|
59 |
"final_dropout": 0.0,
|
60 |
"freeze_feat_extract_train": true,
|
|
|
61 |
"hidden_act": "gelu",
|
62 |
"hidden_dropout": 0.1,
|
63 |
"hidden_size": 768,
|
|
|
120 |
1,
|
121 |
1
|
122 |
],
|
123 |
+
"torch_dtype": "float32",
|
124 |
"transformers_version": "4.46.2",
|
125 |
"use_weighted_layer_sum": false,
|
126 |
"vocab_size": 32,
|
modeling_wav2vec2_spkreg.py
CHANGED
@@ -596,6 +596,9 @@ class AAMSoftmaxLoss(nn.Module):
|
|
596 |
self.easy_margin = easy_margin
|
597 |
self.label_smoothing = label_smoothing
|
598 |
self.reduction = reduction
|
|
|
|
|
|
|
599 |
|
600 |
def forward(
|
601 |
self,
|
@@ -611,9 +614,9 @@ class AAMSoftmaxLoss(nn.Module):
|
|
611 |
"""
|
612 |
_, num_labels = inputs.shape
|
613 |
# `inputs` are the outputs from AngularLinear()
|
614 |
-
cos_theta = torch.clamp(inputs, -1.0
|
615 |
sin_theta = torch.sqrt(1.0 - torch.pow(cos_theta, 2))
|
616 |
-
psi = cos_theta *
|
617 |
# theta = torch.acos(cos_theta)
|
618 |
# psi = torch.cos(theta + self.margin)
|
619 |
one_hot = nn.functional.one_hot(targets, num_labels)
|
|
|
596 |
self.easy_margin = easy_margin
|
597 |
self.label_smoothing = label_smoothing
|
598 |
self.reduction = reduction
|
599 |
+
|
600 |
+
self.cos_m = math.cos(self.margin)
|
601 |
+
self.sin_m = math.sin(self.margin)
|
602 |
|
603 |
def forward(
|
604 |
self,
|
|
|
614 |
"""
|
615 |
_, num_labels = inputs.shape
|
616 |
# `inputs` are the outputs from AngularLinear()
|
617 |
+
cos_theta = torch.clamp(inputs, -1.0, 1.0)
|
618 |
sin_theta = torch.sqrt(1.0 - torch.pow(cos_theta, 2))
|
619 |
+
psi = cos_theta * self.cos_m - sin_theta * self.sin_m # cos(theta + m)
|
620 |
# theta = torch.acos(cos_theta)
|
621 |
# psi = torch.cos(theta + self.margin)
|
622 |
one_hot = nn.functional.one_hot(targets, num_labels)
|