⚗️ | Experimenting, again.

This commit is contained in:
2024-12-26 04:00:24 +02:00
parent 2ff45de22d
commit 89f8c68986
4 changed files with 49 additions and 55 deletions

View File

@ -1,30 +1,31 @@
import torch
import torch.nn as nn
import torch.nn.utils as utils
class SISUDiscriminator(nn.Module):
def __init__(self):
super(SISUDiscriminator, self).__init__()
layers = 32
layers = 8
self.model = nn.Sequential(
nn.Conv1d(1, layers, kernel_size=5, stride=2, padding=2),
utils.spectral_norm(nn.Conv1d(1, layers, kernel_size=7, stride=2, padding=3)),
nn.BatchNorm1d(layers),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv1d(layers, layers * 2, kernel_size=5, stride=2, padding=2),
nn.PReLU(),
nn.Conv1d(layers, layers * 2, kernel_size=7, padding=3),
nn.BatchNorm1d(layers * 2),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv1d(layers * 2, layers * 4, kernel_size=5, stride=2, padding=2),
nn.PReLU(),
nn.Conv1d(layers * 2, layers * 4, kernel_size=5, padding=2),
nn.BatchNorm1d(layers * 4),
nn.LeakyReLU(0.2, inplace=True),
nn.Conv1d(layers * 4, layers * 8, kernel_size=5, stride=2, padding=2),
nn.PReLU(),
nn.Conv1d(layers * 4, layers * 8, kernel_size=3, padding=1),
nn.BatchNorm1d(layers * 8),
nn.LeakyReLU(0.2, inplace=True),
nn.PReLU(),
nn.Conv1d(layers * 8, 1, kernel_size=3, padding=1),
)
self.global_avg_pool = nn.AdaptiveAvgPool1d(1)
self.sigmoid = nn.Sigmoid()
def forward(self, x):
x = x + 0.01 * torch.randn_like(x)
x = self.model(x)
x = self.global_avg_pool(x)
x = x.view(-1, 1)
x = self.sigmoid(x)
return x