Delete evaluation/QP/net.py
Browse files- evaluation/QP/net.py +0 -29
evaluation/QP/net.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
from torch import nn, optim
|
| 3 |
-
|
| 4 |
-
class LossPredictor(nn.Module):
|
| 5 |
-
def __init__(self, ssl_model, ssl_out_dim, dropout_rate=0.2):
|
| 6 |
-
super(LossPredictor, self).__init__()
|
| 7 |
-
self.ssl_model = ssl_model
|
| 8 |
-
self.ssl_features = ssl_out_dim
|
| 9 |
-
self.dropout = nn.Dropout(dropout_rate)
|
| 10 |
-
self.carac_interm = nn.Linear(self.ssl_features,1000) #num dim neurones
|
| 11 |
-
self.output_layer = nn.Linear(1000, 1) #1 neurones
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
def forward(self, wav):
|
| 15 |
-
wav = wav.squeeze(1)
|
| 16 |
-
res = self.ssl_model(wav, mask=False, features_only=True, layer=None)
|
| 17 |
-
x = res['x']
|
| 18 |
-
if 'layer_results' in res:
|
| 19 |
-
layer_outputs = [layer[0] for layer in res['layer_results']] #12 couches
|
| 20 |
-
|
| 21 |
-
concatenated_layers = torch.cat(layer_outputs, dim=-1)
|
| 22 |
-
|
| 23 |
-
x = torch.mean(concatenated_layers, dim=0)
|
| 24 |
-
|
| 25 |
-
x = self.carac_interm(x)
|
| 26 |
-
|
| 27 |
-
x = self.dropout(x) ###Pour le MCDropout pendant train+ pred select candidate
|
| 28 |
-
x = self.output_layer(x)
|
| 29 |
-
return x.squeeze(1) #return loss
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|