RRF / model_skeletons /model_class_3.py
antonypamo's picture
Upload 26 files (#6)
ce680a7 verified
Raw
History Blame Contribute Delete
1.15 kB
# Auto-extracted class source (static)
class SavantRRF_Gauge(nn.Module):
def __init__(self, input_dim, hidden_dim, output_dim):
super(SavantRRF_Gauge, self).__init__()
self.conv1 = nn.Conv1d(input_dim, 64, kernel_size=3, padding=1)
self.conv2 = nn.Conv1d(64, 128, kernel_size=3, padding=1)
self.conv3 = nn.Conv1d(128, 256, kernel_size=3, padding=1)
self.dropout = nn.Dropout(0.25)
# The input size to fc1 is based on the output size of conv3.
# Assuming input sequence length is 160, after 3 conv layers with kernel_size 3 and padding 1,
# the sequence length remains 160. 256 channels * 160 length = 40960.
self.fc1 = nn.Linear(256*160, 512) # Corrected input size based on sequence_length=160
self.fc2 = nn.Linear(512, 256)
self.fc3 = nn.Linear(256, output_dim)
def forward(self, x):
x = F.relu(self.conv1(x))
x = F.relu(self.conv2(x))
x = F.relu(self.conv3(x))
x = torch.flatten(x, 1)
x = self.dropout(x)
x = F.relu(self.fc1(x))
x = F.relu(self.fc2(x))
return torch.sigmoid(self.fc3(x))