This shows you the differences between two versions of the page.
|
gp:laboratoare:07 [2025/03/30 21:11] maria_anca.balutoiu [Layers] |
gp:laboratoare:07 [2025/03/30 21:12] (current) maria_anca.balutoiu [Implementarea unui GAN în PyTorch] |
||
|---|---|---|---|
| Line 45: | Line 45: | ||
| ==== Implementarea unui GAN în PyTorch ==== | ==== Implementarea unui GAN în PyTorch ==== | ||
| - | <hidden> | + | <code> |
| - | </hidden> | + | class Generator(nn.Module): |
| + | def __init__(self): | ||
| + | super(Generator, self).__init__() | ||
| + | self.model = nn.Sequential( | ||
| + | nn.Linear(100, 256), # First linear layer (input: 100 -> 256) | ||
| + | nn.ReLU(), # Activation function | ||
| + | nn.Linear(256, 512), # Second linear layer (256 -> 512) | ||
| + | nn.ReLU(), # Activation function | ||
| + | nn.Linear(512, 1024), # Third linear layer (512 -> 1024) | ||
| + | nn.ReLU(), # Activation function | ||
| + | nn.Linear(1024, 64*64), # Final layer (1024 -> 64x64 terrain) | ||
| + | nn.Tanh() # Activation function for output (-1 to 1) | ||
| + | ) | ||
| + | |||
| + | def forward(self, x): | ||
| + | return self.model(x).view(-1, 64, 64) | ||
| + | </code> | ||
| ==== Tasks ==== | ==== Tasks ==== | ||