yangwang825
commited on
Upload model
Browse files- config.json +5 -3
- modeling_wav2vec2_spkreg.py +4 -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
@@ -612,8 +612,10 @@ class AAMSoftmaxLoss(nn.Module):
|
|
612 |
_, num_labels = inputs.shape
|
613 |
# `inputs` are the outputs from AngularLinear()
|
614 |
cos_theta = torch.clamp(inputs, -1.0 + 1e-7, 1.0 - 1e-7)
|
615 |
-
|
616 |
-
psi =
|
|
|
|
|
617 |
one_hot = nn.functional.one_hot(targets, num_labels)
|
618 |
outputs = self.scale * torch.where(one_hot.bool(), psi, cos_theta)
|
619 |
loss = F.cross_entropy(
|
|
|
612 |
_, num_labels = inputs.shape
|
613 |
# `inputs` are the outputs from AngularLinear()
|
614 |
cos_theta = torch.clamp(inputs, -1.0 + 1e-7, 1.0 - 1e-7)
|
615 |
+
sin_theta = torch.sqrt(1.0 - torch.pow(cos_theta, 2))
|
616 |
+
psi = cos_theta * math.cos(self.margin) - sin_theta * math.sin(self.margin) # cos(theta + m)
|
617 |
+
# theta = torch.acos(cos_theta)
|
618 |
+
# psi = torch.cos(theta + self.margin)
|
619 |
one_hot = nn.functional.one_hot(targets, num_labels)
|
620 |
outputs = self.scale * torch.where(one_hot.bool(), psi, cos_theta)
|
621 |
loss = F.cross_entropy(
|