Dynamic-Net: Tuning the Objective Without Re-Training for Synthesis Tasks

Alon Shoshan, Roey Mechrez, Lihi Zelnik-Manor

Abstract

One of the key ingredients for successful optimization of modern CNNs is identifying a suitable objective. To date, the objective is fixed a-priori at training time, and any variation to it requires re-training a new network. In this paper, we present a first attempt at alleviating the need for re-training. Rather than fixing the network at training time, we train a "Dynamic-Net" that can be modified at inference time. Our approach considers an "objective-space" as the space of all linear combinations of two objectives, and the Dynamic-Net emulates the traversing of this objective-space at test-time, without any further training. We show that this upgrades pre-trained networks by providing an out-of-learning extension, while maintaining performance quality. The solution is fast and allows users to interactively modify the network in real-time to obtain desired results.

The Problem: Fixed Objectives in Deep Learning

In the current deep learning paradigm, the "objective" (the loss function) is typically set in stone before training begins. For synthesis tasks—such as style transfer, face generation, or image completion—this "fixed-point" nature presents several challenges:

  1. User Preference: Artistic taste is subjective. One user might want a subtle "Van Gogh" effect, while another wants a heavy, stylized transformation.
  2. Input Sensitivity: A hyperparameter that works perfectly for one image might produce artifacts or "over-stylization" on another.
  3. Computational Cost: Finding the optimal balance currently requires a "greedy search," where researchers train dozens of separate models with different settings to find the "sweet spot" on the Pareto front.

The Dynamic-Net Framework

Dynamic-Net addresses these issues by introducing a two-phase training strategy that allows users to traverse the "objective-space" at inference time using a single scalar parameter.

Two-Phase Training

The method splits training into two distinct stages:

  • Phase I (The Main Network): A standard "main network" ($\theta$) is trained to minimize a primary objective ($O_0$).
  • Phase II (The Tuning Blocks): The main network is frozen, and small residual "tuning-blocks" ($\psi$) are added at specific layers. These blocks are trained to minimize a different objective ($O_1$). They essentially learn the "direction of change" in the latent feature space required to move from the first objective toward the second.
The Dynamic-Net emulates the Pareto front (blue curve) of two objectives, allowing continuous traversal between fixed networks (Net 1, 2, 3).

Inference-Time Control

At test-time, the user controls a scalar parameter, $\alpha$. The latent representation ($z$) at each tuned layer is calculated as: $$z_{out} = z_{in} + \alpha \cdot \psi(z_{in})$$ * When $\alpha = 0$, the tuning blocks are ignored, yielding the result of the first objective. * When $\alpha = 1$, the tuning blocks are fully active, emulating the second objective. * When $0 < \alpha < 1$, the network effectively interpolates between the two objectives.

This approach relies on the hypothesis that deep networks linearize the manifold of natural images, meaning that linear movement in the feature space corresponds to meaningful semantic changes in the output.

Key Insights and Innovations

Latent Interpolation vs. Image Blending

A common "hack" to achieve intermediate results is to blend the outputs of two different networks. Dynamic-Net demonstrates that interpolating in the latent space produces significantly more natural results. In style transfer, for instance, image blending looks like a simple "fade," whereas Dynamic-Net results in a natural evolution of brushstrokes and textures.

Corrective Tuning and Extrapolation

One of the most surprising findings is that Dynamic-Net can "fix" a sub-optimal main network. If the main network was trained with a loss that produces artifacts, the tuning blocks can steer the model toward a cleaner "working point" post-training. Furthermore, setting $\alpha$ outside the $[0, 1]$ range (e.g., $\alpha = 2.0$) can produce "exaggerated" versions of the objectives that were not explicitly present during training.

Applications and Results

The authors evaluated Dynamic-Net across three distinct synthesis tasks: Style Transfer (MS-COCO), Face Generation (CelebA), and Image Completion (pix2pix).

Dynamic-Net applications across style transfer, face attribute manipulation, and image inpainting.
  • Interactive Control: The system is fast enough for real-time interaction. A user can move a slider and watch a face transition from "Male" to "Female" or "Dark Hair" to "Blond" smoothly.
  • Quantitative Alignment: Performance tests show that the "working points" generated by a single Dynamic-Net closely match the performance of multiple separate networks trained specifically for those points (as seen in the Pareto front plots).
  • Efficiency: Instead of training 10 models to find the best hyperparameter $\lambda$, researchers can train one main network and one set of tuning blocks, effectively covering the entire range of $\lambda$ values.

Conclusion

Dynamic-Net offers a powerful alternative to the "train-once, fix-forever" approach of traditional CNNs. By enabling real-time objective tuning, it empowers users and reduces the computational burden of hyperparameter optimization. While the method is most effective when objectives are moderately related, it opens the door for future research into multi-dimensional objective navigation.

Summary updated

BibTeX
@inproceedings{shoshan2019dynamic,
  author = {Alon Shoshan and Roey Mechrez and Lihi Zelnik-Manor},
  title = {{Dynamic-Net: Tuning the Objective Without Re-Training for Synthesis Tasks}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2019},
  url = {https://openreview.net/forum?id=iIYUVnVjK0q},
}
Figure