# Deep Ritz Residual Trial Network

> Build smooth residual trial networks for Deep Ritz variational PDE objectives.

- Skill: `yzj623/deep-ritz-residual-trial-network` (Agent Skill)
- Install (CLI): `npx get-skill add yzj623/deep-ritz-residual-trial-network`
- Raw SKILL.md: https://api.skillmd.com/api/skills/yzj623/deep-ritz-residual-trial-network/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: yzj623 (https://skillmd.com/u/yzj623)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/yzj623/deep-ritz-residual-trial-network

---


# Deep Ritz Residual Trial Network

## When To Use

Use this skill when a variational PDE solver needs a scalar neural trial function `u(x; theta)` whose spatial gradients can be differentiated. Do not use it for mesh-only PDE discretizations.

## Inputs

- Spatial dimension.
- Hidden width and residual block count.
- Activation choice, preferably cubic ReLU for Poisson-style Deep Ritz losses.
- Coordinate batch with gradient tracking enabled when a loss needs `grad_x u`.

## Outputs

- A trainable scalar model.
- Forward values shaped `[batch, 1]`.
- Input-gradient compatibility for energy losses.

## Workflow

1. Project coordinates into hidden width.
2. Apply residual blocks with two affine transformations and smooth activation.
3. Apply a final linear readout.
4. Keep the model independent of any original implementation repository.

## Validation

Run:

```bash
python tests/test_residual_network.py
```

## Limitations

The helper uses PyTorch when available. If PyTorch is unavailable, tests still validate architecture metadata and deterministic parameter counting, but recovery should record that full autograd training is blocked.

