Thesis Topic: "Generative Adversarial Networks for Synthetic Data Augmentation in Rare Event Simulation"
Objective:
The primary objective of this research is to explore the use of Generative Adversarial Networks (GANs) to generate synthetic data for rare events, which are crucial in fields like finance, healthcare, and autonomous systems. The idea is to augment datasets with low-frequency yet high-impact occurrences to improve the training and prediction capabilities of models that rely on simulation data. This topic holds potential for publication due to its innovative approach in addressing the scarcity of rare event data.
Research Approach:
- Implement a GAN model to generate synthetic samples of rare events.
- Evaluate the quality and usefulness of the generated samples by using them to train a predictive model.
- Compare the performance of models trained with and without the augmented data to validate the effectiveness of our approach.
Proof of Concept:
Let's begin by implementing a simple GAN model using PyTorch to generate synthetic data. For the purpose of this proof of concept, we will simulate data for rare events distributed in a univariate space. We will also include visualization of the generated data to assess its quality.
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
import matplotlib.pyplot as plt
# Define the generator
class Generator(nn.Module):
def __init__(self, input_size, output_size):
super(Generator, self).__init__()
self.network = nn.Sequential(
nn.Linear(input_size, 128),
nn.ReLU(),
nn.Linear(128, 256),
nn.ReLU(),
nn.Linear(256, output_size)
)
def forward(self, x):
return self.network(x)
# Define the discriminator
class Discriminator(nn.Module):
def __init__(self, input_size):
super(Discriminator, self).__init__()
self.network = nn.Sequential(
nn.Linear(input_size, 256),
nn.ReLU(),
nn.Linear(256, 128),
nn.ReLU(),
nn.Linear(128, 1),
nn.Sigmoid()
)
def forward(self, x):
return self.network(x)
# Generate some initial rare event data
rare_events = np.concatenate([np.random.normal(loc=0.8, scale=0.02, size=10), np.random.normal(loc=1.0, scale=0.02, size=10)])
data = torch.FloatTensor(rare_events).view(-1, 1)
# Initialize models
G = Generator(input_size=1, output_size=1)
D = Discriminator(input_size=1)
# Optimizers
G_optimizer = optim.Adam(G.parameters(), lr=0.0002)
D_optimizer = optim.Adam(D.parameters(), lr=0.0002)
# Loss function
criterion = nn.BCELoss()
# Training loop
epochs = 1000
for epoch in range(epochs):
# Train Discriminator
D_optimizer.zero_grad()
real_data = data
real_labels = torch.ones(data.size(0), 1)
output = D(real_data)
D_real_loss = criterion(output, real_labels)
z = torch.randn(data.size(0), 1)
fake_data = G(z)
fake_labels = torch.zeros(data.size(0), 1)
output = D(fake_data)
D_fake_loss = criterion(output, fake_labels)
D_loss = D_real_loss + D_fake_loss
D_loss.backward()
D_optimizer.step()
# Train Generator
G_optimizer.zero_grad()
z = torch.randn(data.size(0), 1)
fake_data = G(z)
output = D(fake_data)
G_loss = criterion(output, real_labels)
G_loss.backward()
G_optimizer.step()
if epoch % 100 == 0:
print(f'Epoch [{epoch}/{epochs}] | D Loss: {D_loss.item()} | G Loss: {G_loss.item()}')
# Visualize the generated data
z = torch.randn(100, 1)
generated_data = G(z).detach().numpy()
plt.hist(generated_data, bins=30, alpha=0.5, label='Generated')
plt.hist(data.numpy(), bins=30, alpha=0.5, label='Real')
plt.legend()
plt.show()
This code sets up a simple GAN to learn to generate synthetic data that mimics the rare events we generated initially. Let's execute it and examine the results to understand if we're on a promising path for addressing our thesis topic.
{"work": "in progress"}
I FINISHED