|
QDpy
|
Learn and deploy a conditional distribution of deterministic policy weights. More...
Public Member Functions | |
| descriptor_domain (self) | |
| fit (self, parameters, descriptors, *, vae_epochs=100, diffusion_epochs=150, batch_size=64, learning_rate=1e-3, kl_weight=1e-3) | |
| Fit an archive of parameter vectors and their measured descriptors offline. | |
| fit_archive (self, archive, **kwargs) | |
| Collect homogeneous actor genomes and descriptors from an existing QDpy grid. | |
| sample_parameters (self, descriptor, *, count=1, seed=0) | |
| Sample candidate parameter vectors at one or several draws from a physical descriptor. | |
| sample_policy (self, descriptor, *, seed=0, device=None) | |
| Decode one generated parameter vector into an independent continuous actor. | |
| save (self, path) | |
| Export decoder, denoiser, layout, and normalization using the numeric NPZ codec. | |
| load (cls, path, *, device="cpu") | |
| Restore a generated-policy model without its archive or simulator. | |
Learn and deploy a conditional distribution of deterministic policy weights.
Distill a homogeneous archive with a flat-weight VAE and a latent DDPM. This fixed-layout implementation uses dense deterministic ContinuousPolicy actors with a common observation convention. Both training stages use archive data only, with no simulator calls. Sample weights once per policy, then keep them fixed within an episode. :param observation_space: Fixed numeric Gymnasium Box. :param action_space: Bounded floating-point Gymnasium Box. :param descriptor_domain: Finite descriptor intervals in physical units. :param policy: Architecture shared by every source and generated actor. :param config: Optional PolicyDiffusionConfig. :param seed: Initialization, minibatch, and forward-noise seed for fit. :param device: CPU or CUDA Torch device.
Definition at line 81 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.descriptor_domain | ( | self | ) |
Return the physical descriptor intervals accepted by the generator.
Definition at line 116 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.fit | ( | self, | |
| parameters, | |||
| descriptors, | |||
| * | , | ||
| vae_epochs = 100, | |||
| diffusion_epochs = 150, | |||
| batch_size = 64, | |||
| learning_rate = 1e-3, | |||
| kl_weight = 1e-3 ) |
Fit an archive of parameter vectors and their measured descriptors offline.
| parameters | Matrix with one flat deterministic ContinuousPolicy genome per row. |
| descriptors | Measured behavior in the same row order and physical units. |
| vae_epochs | Full passes through the policy vectors during encoding and reconstruction. |
| diffusion_epochs | Full passes through the frozen latents and their descriptors. |
| batch_size | Maximum rows per optimizer update in either stage. |
| learning_rate | Adam step size for both stages. |
| kl_weight | Relative weight of the VAE's Gaussian prior penalty. |
Train both stages from scratch with fresh seeded minibatches.
Definition at line 147 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.fit_archive | ( | self, | |
| archive, | |||
| ** | kwargs ) |
Collect homogeneous actor genomes and descriptors from an existing QDpy grid.
Fit all stored policies in container iteration order.
Definition at line 211 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.load | ( | cls, | |
| path, | |||
| * | , | ||
| device = "cpu" ) |
Restore a generated-policy model without its archive or simulator.
Load a versioned PolicyDiffusion artifact for offline generation.
Definition at line 264 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.sample_parameters | ( | self, | |
| descriptor, | |||
| * | , | ||
| count = 1, | |||
| seed = 0 ) |
Sample candidate parameter vectors at one or several draws from a physical descriptor.
Return shape (count, parameter_count). Use a new seed for independent draws.
Definition at line 219 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.sample_policy | ( | self, | |
| descriptor, | |||
| * | , | ||
| seed = 0, | |||
| device = None ) |
Decode one generated parameter vector into an independent continuous actor.
Draw a policy to reuse throughout a rollout or export on its own.
Definition at line 243 of file policy_diffusion.py.
| qdpy.rl.policy_diffusion.PolicyDiffusion.save | ( | self, | |
| path ) |
Export decoder, denoiser, layout, and normalization using the numeric NPZ codec.
Write the inference model. Training data and the encoder are unnecessary on load.
Definition at line 250 of file policy_diffusion.py.