Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Isaac sim IsaacGymEnvs AMPBuilder

From Leeroopedia
Knowledge Sources
Domains Reinforcement_Learning, Neural_Network_Architecture
Last Updated 2026-02-15 11:00 GMT

Overview

AMPBuilder is a network builder class that extends the standard A2C network architecture with a discriminator MLP for Adversarial Motion Priors (AMP) training.

Description

The AMPBuilder class inherits from A2CBuilder provided by rl_games and adds discriminator network construction on top of the standard actor-critic architecture. Its primary role is to build a neural network that includes both the policy/value heads required for PPO training and a separate discriminator head used for AMP-style motion imitation rewards.

The inner Network class performs the actual network construction. During initialization, it calls the parent A2CBuilder.Network to set up the standard actor and critic streams, then invokes _build_disc() to construct the discriminator MLP. The discriminator architecture is configured through the disc section of the network parameters, which specifies the hidden units, activation function, and weight initializer. The final discriminator output is a single logit produced by a linear layer, initialized with a scale controlled by the constant DISC_LOGIT_INIT_SCALE = 1.0.

Key methods on the Network include eval_disc(amp_obs) which runs AMP observations through the discriminator MLP to produce logits, eval_critic(obs) which evaluates the value function, get_disc_logit_weights() which returns the final discriminator layer weights for gradient penalty computation, and get_disc_weights() which returns all discriminator weights for regularization. The load() method parses the discriminator configuration from the params dictionary.

Usage

Use AMPBuilder when setting up AMP-based training environments. It is registered as the network builder for AMP tasks and is automatically instantiated by the rl_games framework. The discriminator parameters (units, activation, initializer) are configured in the YAML training configuration under the network.disc key.

Code Reference

Source Location

Signature

DISC_LOGIT_INIT_SCALE = 1.0

class AMPBuilder(network_builder.A2CBuilder):
    def __init__(self, **kwargs):
    def build(self, name, **kwargs):

    class Network(network_builder.A2CBuilder.Network):
        def __init__(self, params, **kwargs):
        def load(self, params):
        def eval_critic(self, obs):
        def eval_disc(self, amp_obs):
        def get_disc_logit_weights(self):
        def get_disc_weights(self):
        def _build_disc(self, input_shape):

Import

from isaacgymenvs.learning.amp_network_builder import AMPBuilder

I/O Contract

Inputs

Name Type Required Description
params dict Yes Network parameters containing disc key with units (list of ints), activation (str), and initializer (dict)
amp_input_shape tuple Yes Shape of the AMP observation input, passed via kwargs during Network construction
amp_obs torch.Tensor Yes AMP observation tensor passed to eval_disc() for discriminator evaluation

Outputs

Name Type Description
net AMPBuilder.Network The constructed network instance with actor, critic, and discriminator heads
disc_logits torch.Tensor Discriminator output logits from eval_disc(), shape (batch_size, 1)
disc_weights list[torch.Tensor] Flattened weight tensors from all discriminator layers, returned by get_disc_weights()

Usage Examples

from isaacgymenvs.learning.amp_network_builder import AMPBuilder

# Create and configure the builder
builder = AMPBuilder()
network_params = {
    'mlp': {
        'units': [1024, 512],
        'activation': 'relu',
        'initializer': {'name': 'default'},
    },
    'disc': {
        'units': [1024, 512],
        'activation': 'relu',
        'initializer': {'name': 'default'},
    },
}
builder.load(network_params)

# Build the network
net = builder.build(
    'amp',
    input_shape=(obs_size,),
    amp_input_shape=(amp_obs_size,),
    actions_num=action_size,
)

# Evaluate discriminator on AMP observations
disc_logits = net.eval_disc(amp_obs_tensor)

# Get discriminator weights for gradient penalty
disc_weights = net.get_disc_weights()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment