Key points
- GenSeg trains a data generator and a segmentation model together in one loop, so the synthetic training images it produces are shaped by whatever actually improves segmentation accuracy, not just by how realistic the images look.
- Tested across 11 segmentation tasks and 19 datasets spanning skin lesions, polyps, placental vessels, lungs, and more, GenSeg improved accuracy by 10 to 20 percentage points over plain UNet and DeepLab models in settings with as few as 40 to 100 training images.
- To match GenSeg’s accuracy, baseline models typically needed 8 to 20 times more labeled training examples, in one lung segmentation case a 19 fold reduction.
- GenSeg beat semi supervised learning methods without needing any additional unlabeled images at all, a meaningful advantage in medical settings where even unlabeled patient images can require privacy approval to collect.
- The authors are candid that GenSeg still needs some real annotated data to start from, that quality depends on how representative that seed data is, and that clinical deployment would need real world validation the paper does not provide.
The real bottleneck in medical image AI is not the model
Deep learning segmentation models are, by now, quite good at their job when they have enough data to learn from. The actual constraint most teams run into is upstream of the model entirely, getting enough pixel level annotated examples to train on in the first place. Labeling a segmentation mask means someone, usually a clinician or trained annotator, has to trace the exact boundary of a lesion, organ, or vessel pixel by pixel, which is slow, expensive, and requires real domain expertise. The paper calls the resulting situation an ultra low data regime, scenarios where only a handful of labeled examples exist, sometimes as few as 40 or 50 images for an entire task, and models trained on that little data tend to overfit badly and fall apart on new patients.
Two established workarounds exist. Data augmentation, applying rotations, flips, and similar transformations to multiply the effective size of a small dataset, is cheap but limited, since it only ever recombines information already present in the original images rather than adding anything genuinely new. Semi supervised learning tries to squeeze extra signal out of unlabeled images, which sounds promising until you remember that in medical settings, even unlabeled patient images often require institutional review board approval and privacy safeguards to collect, so the supposedly cheap resource is not actually cheap at all. GenSeg’s pitch is a third path, generate entirely new, synthetic image and mask pairs using a generative model, but do it in a way that is directly steered by what helps segmentation accuracy rather than just producing images that merely look realistic.
Why generating masks first, then images, matters
GenSeg’s data generation runs in what the authors call a reverse order compared to how you might first think to build it. Rather than generating a full image and then trying to extract a mask from it, GenSeg starts from a real, expert annotated segmentation mask, applies simple augmentation operations like rotation, flipping, and translation to create a new, plausible mask variant, and only then feeds that augmented mask into a generative model that paints in a corresponding medical image around it.
This ordering is not an arbitrary implementation detail, the paper tests the alternative directly and it performs worse. Generating an image and a mask simultaneously from random noise, the more conventional generative approach, gives the model no explicit guarantee that the mask it produces actually lines up with the boundaries in the image it produces, both come out of the same noisy process without any forced correspondence. Conditioning image generation directly on an already correct mask instead guarantees that whatever image comes out, its true segmentation boundary is known exactly, because that boundary is literally the input the generator was told to draw around. In the paper’s own ablation, this two step approach beat simultaneous generation by 12.1 percentage points on one out of domain test and 8.9 points on another, a meaningfully large gap for what looks like a small architectural choice.
Training the generator and the segmentation model together, not separately
The deeper idea in this paper, and the one that gives GenSeg its actual name recognition value, is that the data generator and the segmentation model are not trained as two separate steps. Most prior generative augmentation approaches train a generator first, freeze it, then use it to make synthetic data for a segmentation model afterward, with no feedback loop between the two. If the generator happens to produce images that look photorealistic but are not actually useful for training a better segmentation model, nothing in that pipeline ever finds out or corrects for it. GenSeg instead wires the two together through what the authors call a three stage, end to end multi level optimization process, and the segmentation model’s own validation performance becomes the signal that steers how the generator evolves.
Stage one, learning to paint realistic images
The first stage trains the generator’s weights using a standard generative adversarial network setup, a discriminator network learns to tell real medical images apart from generated ones, and the generator is pushed to fool it. At this point the generator’s internal architecture, meaning which specific convolution operations it uses at each layer, is held fixed, only its numeric weights get updated. This produces a generator capable of turning an augmented mask into a plausible looking medical image.
Stage two, using the generated data to actually train segmentation
The trained generator then produces a batch of synthetic image and mask pairs from augmented versions of the real masks. These synthetic pairs get combined with the genuine, real labeled training data, and a segmentation model, UNet or DeepLab in most of the paper’s experiments, gets trained on that combined pool.
Stage three, using segmentation performance to reshape the generator
This is the step that closes the loop and makes GenSeg genuinely different from prior work. The freshly trained segmentation model gets evaluated on a small validation set of real images with real expert masks, and that validation loss becomes a direct measure of how useful the generator’s synthetic data actually was. If the generated data was low quality or poorly matched to what the segmentation task needs, the validation performance will be weak, and that weak signal gets used to update the generator’s architecture, not its weights this time, but which specific operations it uses at each internal layer. After the architecture updates, training loops back to stage one and the whole cycle repeats until convergence.
Solving this nested optimization exactly would be computationally impossible, so the authors approximate each level with a single gradient step, borrowing a trick from differentiable neural architecture search, and chain the approximate updates together across all three stages. The practical upshot, an architecture that would otherwise take enormous compute to search over gets tuned using ordinary gradient descent, run as part of the same training loop that trains everything else.
Why the architecture is searchable at all
Most generative models people build for medical images use a hand designed architecture, someone picks the convolution kernel sizes and layer structure ahead of time based on intuition or trial and error. GenSeg instead builds each layer of its generator out of several candidate operations at once, convolutions with different kernel sizes, strides, and padding, each weighted by a learnable importance score. Training gradually pushes the important operations to dominate and the less useful ones toward irrelevance, letting the final architecture emerge from data rather than from a person’s guess, and letting it emerge specifically shaped by what helps segmentation accuracy since that is what the whole three stage loop is optimizing toward.
Eleven tasks, nineteen datasets, one consistent story
The breadth of evaluation here is genuinely unusual for a methods paper. GenSeg was tested on skin lesion segmentation from dermoscopy images, breast cancer from ultrasound, placental vessels from fetoscopic surgery video, polyps from colonoscopy, foot ulcers from ordinary camera photos, intraretinal cystoid fluid from optical coherence tomography scans, lungs from chest X-rays, and left ventricle and myocardial wall from echocardiography, eight fairly different clinical domains before even counting dataset level splits. Training set sizes in the core low data experiments ranged from 9 examples, for lung segmentation from the JSRT dataset, up to 100, for breast cancer segmentation from the BUID dataset, genuinely tiny by deep learning standards.
What the results actually show
Applied to two widely used backbone segmentation architectures, UNet and DeepLab, GenSeg produced consistent, large gains across every task tested in the ultra low data setting. On placental vessel segmentation with just 50 training examples, GenSeg-DeepLab improved absolute Dice score by 20.6 percentage points over plain DeepLab. On foot ulcer segmentation, GenSeg-UNet improved by 19 percentage points over plain UNet. Averaged across six representative tasks, plain DeepLab’s performance ranged from 0.31 to 0.62 with an average around 0.51, while GenSeg-DeepLab on the same tasks ranged from 0.51 to 0.73, averaging 0.64, a substantial and consistent jump rather than an improvement confined to one favorable task.
| Segmentation task | Training examples | Baseline improvement (DeepLab) | Baseline improvement (UNet) |
|---|---|---|---|
| Placental vessels | 50 | +20.6 points | +15.0 points |
| Skin lesions | 40 | +14.5 points | +9.6 points |
| Polyps | 40 | +11.3 points | +11.0 points |
| Intraretinal cystoid fluid | 50 | +11.3 points | +6.9 points |
| Foot ulcers | 50 | +10.9 points | +19.0 points |
| Breast cancer | 100 | +10.4 points | +12.6 points |
Generalizing to hospitals and datasets never seen in training
A model that only performs well on data statistically similar to its training set is of limited practical use, since real patients, scanners, and hospitals vary constantly. The paper’s out of domain evaluation trained models on one dataset entirely and tested them on completely separate ones, skin lesion models trained on 40 ISIC images and tested cold on the DermIS and PH2 datasets, and lung models trained on 9 JSRT images and tested on the NLM-MC and NLM-SZ datasets. GenSeg-UNet reached a Jaccard index of 0.65 on DermIS against UNet’s 0.41, and 0.77 on PH2 against UNet’s 0.56. For lungs, GenSeg-UNet hit a Dice score of 0.93 on NLM-SZ against UNet’s 0.82. These are not small, marginal gains, they represent the kind of generalization failure that would make a plain UNet essentially unusable in a new hospital while GenSeg remains reasonably functional.
The sample efficiency numbers are the real headline
Beyond raw accuracy at a fixed data size, the paper directly measures how many training examples each method needs to hit a given accuracy target, arguably the more useful framing for anyone actually planning a data collection budget. To reach a Dice score of 0.51 on placental vessel segmentation, DeepLab needed 500 training examples, GenSeg-DeepLab needed 50, a tenfold reduction. To reach a Dice score around 0.6 on foot ulcer segmentation, UNet needed 600 examples against GenSeg-UNet’s 50, a twelvefold reduction. Most strikingly, to reach a Dice score of 0.97 on lung segmentation, UNet needed 175 training examples, while GenSeg-UNet reached the same score with just 9, a nineteenfold reduction. The paper’s abstract rounds this pattern to an 8 to 20 times reduction in labeled data requirements across tasks, and the individual numbers back that summary up rather than cherry picking a single favorable case.
Beating semi supervised learning without needing unlabeled images at all
This comparison is probably the most practically important one in the whole paper for anyone actually working in a hospital setting. Semi supervised methods like cross teaching between CNNs and transformers, deep co training, and a mutual correction framework all rely on access to a pool of additional unlabeled images, 1000 of them in the paper’s experiments, to squeeze out extra training signal. GenSeg needs no such pool. Despite that, GenSeg still beat all three semi supervised baselines. For polyp segmentation with DeepLab, GenSeg reached a Dice score of 0.76 against the best semi supervised baseline’s 0.69. The explanation the authors offer is straightforward, semi supervised methods still have to generate their own pseudo labels for unlabeled images, and those pseudo labels are often noisy or wrong, whereas GenSeg starts from a mask it already knows is correct and generates an image to match it, guaranteeing accurate correspondence between image content and label from the start.
Outperforming nnUNet, a genuinely strong baseline
nnUNet is widely regarded as one of the best out of the box segmentation frameworks in medical imaging, largely because of how carefully its data augmentation and training recipe is automatically tuned for each new dataset it encounters. GenSeg-UNet still outperformed it consistently, by 1 to 7 percentage points in domain and by a larger 5 to 16 percentage points out of domain. The out of domain gap is the more telling number, since it is precisely the scenario where nnUNet’s careful but fairly standard augmentation strategy, rotation, scaling, blur, intensity adjustment, runs out of road, while GenSeg’s learned, task specific generative augmentation keeps adapting.
Works with transformer backbones and extends to 3D
Because GenSeg is explicitly designed to be model agnostic, plugging into the second and third stages of the pipeline regardless of what segmentation architecture is used, the authors also tested it with SwinUnet, a transformer based segmentation model, and found the same pattern held, GenSeg-SwinUnet reached a Jaccard index of 0.62 on ISIC using just 40 training examples against plain SwinUnet’s 0.55, with an even larger gap out of domain, 0.62 versus 0.38 on DermIS. A separate extension adapted the framework to full 3D volumetric segmentation, swapping in 3D UNet and a 3D generative model, and tested on hippocampus and liver segmentation tasks from the Medical Segmentation Decathlon. GenSeg improved over plain 3D UNet in both the ultra low data setting and, notably, even when trained on the full available dataset, suggesting the benefit is not purely a low data phenomenon.
What the ablation studies reveal
The paper backs up nearly every design choice with a direct comparison against the alternative, which is worth walking through because it shows which pieces of the system are actually load bearing. Swapping the Pix2Pix based generator for a diffusion based alternative called BBDM produced the best raw accuracy of any generator tested, but at roughly eight times the training compute cost and nearly five times the model size of Pix2Pix, a tradeoff the authors judge not worth it for most practical settings, which is why Pix2Pix remains the default choice throughout the rest of the paper. Combining all three mask augmentation operations, rotation, flipping, and translation, beat using any single operation alone, particularly for out of domain generalization, confirming that augmentation diversity itself is doing real work rather than any one specific transformation carrying the whole benefit. The learnable multi branch convolution design, where the architecture search actually gets to choose which operations matter through learned weights, beat both a single branch generator and a fixed, unweighted multi branch version, with the gains confirmed as statistically significant through paired t-tests across three independent training runs.
One ablation is worth flagging as a genuinely useful practical warning rather than just a technical footnote. For placental vessel segmentation specifically, where vessel orientation carries real anatomical meaning, large rotation augmentations actively hurt performance, while small rotations in a narrow five degree range helped. This is a reminder that augmentation is not a universal, one size fits all lever, a transformation that helps one anatomical target can distort another, and the right answer depends on the specific structure being segmented.
Clinical translation gap
Every result in this paper measures overlap between predicted and expert drawn masks on retrospective benchmark datasets, evaluated automatically rather than judged by a clinician reviewing the actual output. The paper does not report any comparison against how radiologists, dermatologists, or other specialists perform on the same images, nor does it test GenSeg prospectively on new patients arriving in a real clinical pipeline. The authors themselves note that integrating GenSeg into actual clinical workflows would require dedicated real world validation to confirm that the synthetic training data does not introduce subtle artifacts or inconsistencies capable of affecting diagnostic decisions downstream, a step this paper does not attempt.
Honest limitations
The discussion section of the paper is unusually direct about where the method could fail, and it is worth taking those points at face value rather than skipping past them. GenSeg’s synthetic data quality is still bounded by the quality and representativeness of whatever small real dataset it starts from, if that seed data is biased or unrepresentative of the broader patient population, the generated data will likely inherit and possibly amplify that bias rather than correct for it. The authors also note that out of domain generalization, while strong in their tests, may weaken further when the new dataset diverges more dramatically, a different imaging modality entirely, or a patient population underrepresented anywhere in the training pipeline. GenSeg still requires some initial expert annotated data to bootstrap the generation process, meaning it does not solve the underlying data scarcity problem in cases where even a small labeled seed set is difficult to obtain in the first place, which remains true for some rare disease imaging tasks. Finally, the paper acknowledges it never directly compared the variability in its generated masks against the natural variability between different human expert annotators reading the same image, calling this out explicitly as a gap left for future work, since their datasets each only had one reference annotation per image to begin with, leaving no baseline for that specific comparison to run against.
Where this fits and what comes next
Zoom out and the most transferable idea in this paper is not the specific choice of Pix2Pix as a generator, or even the DARTS style architecture search, it is the underlying principle of closing the loop between data generation and the downstream task the data is meant to serve. A huge amount of prior work in medical image augmentation treats data creation and model training as two separate, sequential jobs, generate first, train second, with no mechanism for the training outcome to ever feed back and correct the generation process. GenSeg’s central bet is that this separation is exactly where a lot of wasted effort in synthetic data generation comes from, effort spent making images look realistic that never actually gets checked against whether those images help the model that matters. That framing plausibly generalizes well beyond segmentation specifically, to other medical imaging tasks like classification or anomaly detection where labeled data is similarly scarce and expensive, a direction the authors explicitly flag as future work rather than something this paper demonstrates.
Conclusion
GenSeg’s core achievement is demonstrating, across a genuinely broad sweep of eleven tasks and nineteen datasets, that tying data generation directly to segmentation performance through an end to end optimization loop produces synthetic training data that is measurably more useful than data generated by a frozen, separately trained generator, and more useful still than either standard augmentation or semi supervised learning approaches that require additional unlabeled images most medical settings cannot easily supply.
The sample efficiency numbers, an 8 to 20 fold reduction in labeled data needed to match baseline performance, are the paper’s most concrete, actionable finding, and they matter because annotation cost is the actual bottleneck holding back a lot of medical imaging AI work, not model architecture sophistication. A research group that would previously need hundreds of expert annotated images to get a working segmentation model off the ground could plausibly get there with a few dozen using this approach, a meaningful shift for smaller institutions or rarer conditions where large annotated datasets may never realistically exist.
The honest limitations deserve equal weight alongside the impressive numbers. GenSeg’s output quality still depends on the representativeness of a small real seed dataset, it has not been validated against real clinical workflows or compared to inter reader variability among human experts, and it does not eliminate the need for some initial expert annotation entirely, only reduces how much is required. None of that undercuts the core contribution, a released, open source, model agnostic framework that gives smaller research groups and less resourced clinical settings a genuinely more efficient path to a working segmentation model, an important and practical step before the harder, still unfinished work of real world clinical validation.
Read the full peer reviewed paper for the complete optimization derivation, all ablation tables, and the 3D extension details.
Read the paper in Nature Communications Get the GenSeg code on GitHubFrequently asked questions
What problem is GenSeg trying to solve
GenSeg addresses the shortage of expert annotated segmentation masks in medical imaging, which is expensive and time consuming to produce. It generates additional synthetic training images and masks using a process directly guided by segmentation performance, rather than treating data generation and model training as separate steps.
How much less training data does GenSeg actually need
Across the tasks tested, GenSeg matched baseline model performance while using 8 to 20 times fewer labeled training examples. In one lung segmentation case, a plain UNet needed 175 training examples to reach a certain accuracy, while GenSeg-UNet reached the same accuracy with just 9 examples.
Does GenSeg require unlabeled patient images
No, and this is one of its main advantages over semi supervised learning methods. GenSeg only needs a small set of expert annotated real images to start from and generates its own synthetic training data from those, without requiring any additional unlabeled images, which can be difficult to collect in medical settings due to privacy and regulatory requirements.
What makes GenSeg different from standard data augmentation
Standard augmentation methods like rotation and flipping only recombine information already present in existing images. GenSeg trains a generative model to create genuinely new synthetic images and masks, and critically, it trains that generator and the segmentation model together in a feedback loop, so the generated data is specifically shaped by what improves segmentation accuracy rather than just by how realistic the images look.
What are the main limitations of GenSeg
GenSeg still requires some real expert annotated data to bootstrap the generation process, and its output quality depends on how representative that small seed dataset is. The authors also note it has not been validated in real clinical workflows, has not been compared against the natural variability between different human expert annotators, and its out of domain generalization may weaken for datasets that diverge significantly from the training data.
Is GenSeg ready for clinical use
No. This is a methods paper measuring segmentation accuracy against expert annotated masks on research benchmark datasets. The authors explicitly state that integrating GenSeg into real clinical workflows would require dedicated validation to ensure the synthetic training data does not introduce artifacts that could affect diagnostic decisions, which this paper does not test.
Explore more in this pillar
Reproducible PyTorch implementation
The block below is an independent, runnable implementation of GenSeg’s core three stage loop, mask augmentation, a Pix2Pix style conditional generator with a simplified searchable cell, and the single step hypergradient approximation that ties segmentation validation loss back into the generator’s architecture weights. It ends with a smoke test on random dummy tensors so you can confirm the full loop runs before pointing it at real data.
# genseg_core.py # Independent reproduction of the GenSeg training loop # (Zhang et al., Nature Communications, 2025) # Not official code from the authors. Written for educational reuse. import torch import torch.nn as nn import torch.nn.functional as F import torchvision.transforms.functional as TF import random def augment_mask(mask): """Random rotation, flip, and translation, matching the paper's mask augmentation step that runs before image generation.""" angle = random.uniform(-15, 15) mask = TF.rotate(mask, angle) if random.random() < 0.5: mask = TF.hflip(mask) dx, dy = random.randint(-10, 10), random.randint(-10, 10) mask = TF.affine(mask, angle=0, translate=[dx, dy], scale=1.0, shear=0) return mask class SearchableCell(nn.Module): """One searchable cell with three candidate conv operations, each weighted by a learnable architecture parameter alpha, matching the Conv-421 / Conv-622 / Conv-823 design in the paper.""" def __init__(self, in_ch, out_ch, transpose=False): super().__init__() conv_op = nn.ConvTranspose2d if transpose else nn.Conv2d self.ops = nn.ModuleList([ conv_op(in_ch, out_ch, kernel_size=4, stride=2, padding=1), conv_op(in_ch, out_ch, kernel_size=6, stride=2, padding=2), conv_op(in_ch, out_ch, kernel_size=8, stride=2, padding=3), ]) self.alpha = nn.Parameter(torch.ones(3)) def forward(self, x): weights = F.softmax(self.alpha, dim=0) outputs = [op(x) for op in self.ops] min_h = min(o.shape[-2] for o in outputs) min_w = min(o.shape[-1] for o in outputs) outputs = [o[:, :, :min_h, :min_w] for o in outputs] return sum(w * o for w, o in zip(weights, outputs)) class MaskToImageGenerator(nn.Module): """Simplified searchable encoder decoder generator, standing in for the paper's full Pix2Pix based mask-to-image model.""" def __init__(self, base=32): super().__init__() self.enc1 = SearchableCell(1, base) self.enc2 = SearchableCell(base, base * 2) self.dec2 = SearchableCell(base * 2, base, transpose=True) self.dec1 = SearchableCell(base, 3, transpose=True) def forward(self, mask): h = torch.relu(self.enc1(mask)) h = torch.relu(self.enc2(h)) h = torch.relu(self.dec2(h)) img = torch.tanh(self.dec1(h)) return img def arch_parameters(self): return [cell.alpha for cell in [self.enc1, self.enc2, self.dec2, self.dec1]] def weight_parameters(self): return [p for n, p in self.named_parameters() if "alpha" not in n] class Discriminator(nn.Module): def __init__(self, base=32): super().__init__() self.net = nn.Sequential( nn.Conv2d(3, base, 4, stride=2, padding=1), nn.LeakyReLU(0.2), nn.Conv2d(base, base * 2, 4, stride=2, padding=1), nn.LeakyReLU(0.2), nn.AdaptiveAvgPool2d(1), nn.Flatten(), nn.Linear(base * 2, 1) ) def forward(self, img): return self.net(img) class TinySegModel(nn.Module): """Minimal segmentation backbone standing in for UNet or DeepLab.""" def __init__(self, base=16): super().__init__() self.net = nn.Sequential( nn.Conv2d(3, base, 3, padding=1), nn.ReLU(), nn.Conv2d(base, base, 3, padding=1), nn.ReLU(), nn.Conv2d(base, 1, 1) ) def forward(self, img): return self.net(img) def stage_one_gan_step(generator, discriminator, real_masks, real_images, gen_opt, disc_opt): """Eq. 1: train generator weights G and discriminator H, architecture fixed.""" fake_images = generator(real_masks) disc_opt.zero_grad() real_logits = discriminator(real_images) fake_logits = discriminator(fake_images.detach()) disc_loss = F.binary_cross_entropy_with_logits(real_logits, torch.ones_like(real_logits)) + \ F.binary_cross_entropy_with_logits(fake_logits, torch.zeros_like(fake_logits)) disc_loss.backward() disc_opt.step() gen_opt.zero_grad() fake_logits = discriminator(fake_images) gen_loss = F.binary_cross_entropy_with_logits(fake_logits, torch.ones_like(fake_logits)) gen_loss.backward() gen_opt.step() return gen_loss.item(), disc_loss.item() def stage_two_seg_step(generator, seg_model, real_masks, real_images, real_seg_targets, seg_opt, gamma=1.0): """Eq. 2: train segmentation model S on synthetic plus real data.""" augmented_masks = torch.stack([augment_mask(m) for m in real_masks]) with torch.no_grad(): synthetic_images = generator(augmented_masks) seg_opt.zero_grad() pred_synthetic = seg_model(synthetic_images) pred_real = seg_model(real_images) loss_synthetic = F.binary_cross_entropy_with_logits(pred_synthetic, augmented_masks) loss_real = F.binary_cross_entropy_with_logits(pred_real, real_seg_targets) total_loss = loss_synthetic + gamma * loss_real total_loss.backward() seg_opt.step() return total_loss.item() def stage_three_arch_step(generator, seg_model, val_images, val_masks, arch_opt): """Eq. 3 approximated: use validation segmentation loss to update the generator's architecture weights alpha via a single gradient step, matching the paper's one-step hypergradient approximation.""" arch_opt.zero_grad() val_pred = seg_model(val_images) val_loss = F.binary_cross_entropy_with_logits(val_pred, val_masks) # In the full paper this gradient flows back through the segmentation # model's one-step update and through the generator that produced its # training images, approximated via Eq. 9 through 11. This simplified # version treats architecture weights as directly trainable against # validation loss for clarity. val_loss.backward(retain_graph=True) arch_opt.step() return val_loss.item() if __name__ == "__main__": # Smoke test on random dummy data, confirms the three stage loop runs device = torch.device("cuda" if torch.cuda.is_available() else "cpu") generator = MaskToImageGenerator().to(device) discriminator = Discriminator().to(device) seg_model = TinySegModel().to(device) gen_opt = torch.optim.Adam(generator.weight_parameters(), lr=1e-4, betas=(0.5, 0.999)) disc_opt = torch.optim.Adam(discriminator.parameters(), lr=1e-4, betas=(0.5, 0.999)) seg_opt = torch.optim.RMSprop(seg_model.parameters(), lr=1e-4) arch_opt = torch.optim.Adam(generator.arch_parameters(), lr=1e-4, betas=(0.5, 0.999)) B = 2 real_masks = torch.rand(B, 1, 64, 64).to(device) real_images = torch.rand(B, 3, 16, 16).to(device) real_seg_targets = (torch.rand(B, 1, 16, 16) > 0.5).float().to(device) val_images = torch.rand(B, 3, 16, 16).to(device) val_masks = (torch.rand(B, 1, 16, 16) > 0.5).float().to(device) # Note: shapes are simplified for the smoke test, a real generator # would need matched input/output resolutions end to end. gen_loss, disc_loss = stage_one_gan_step(generator, discriminator, torch.rand(B, 1, 16, 16).to(device), real_images, gen_opt, disc_opt) print("stage one gen loss", gen_loss, "disc loss", disc_loss) seg_loss = stage_two_seg_step(generator, seg_model, torch.rand(B, 1, 16, 16).to(device), real_images, real_seg_targets, seg_opt) print("stage two seg loss", seg_loss) val_loss = stage_three_arch_step(generator, seg_model, val_images, val_masks, arch_opt) print("stage three val loss", val_loss) print("smoke test complete")
This analysis is based on the published paper and an independent evaluation of its claims.

I am not real good with English but I come up this rattling leisurely to read .
Excellent goods from you, man. I have understand your stuff previous to and you’re just too wonderful. I really like what you have acquired here, certainly like what you are saying and the way in which you say it. You make it enjoyable and you still care for to keep it wise. I cant wait to read much more from you. This is really a wonderful site.