Views
No views yet
thuerey-group/pde-transformer, further trained on synthetic solutions of the
2D diffusion / heat equation with Gaussian bump initial conditions.Input: 2-channel field[u(t0), u(t1)]
Output: next-step predictionu(t2)(via channel index 1 in the model output)
1import torch
2from pdetransformer.core.mixed_channels import PDETransformer
3
4device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
5
6# Load fine-tuned model from Hugging Face
7model = PDETransformer.from_pretrained(
8 "saipuppala/diffusion_transformer"
9).to(device)
10model.eval()
11
12# Example input: batch of size 1, 2 time steps, 64x64 grid
13# x[..., 0, :, :] ~ u(t0), x[..., 1, :, :] ~ u(t1)
14x = torch.randn((1, 2, 64, 64), dtype=torch.float32, device=device)
15
16with torch.no_grad():
17 out = model(x) # model output (tensor / dict / object)
18 pred_all = out if isinstance(out, torch.Tensor) else (
19 getattr(out, "prediction", None)
20 or getattr(out, "sample", None)
21 or next(v for v in out.values() if isinstance(v, torch.Tensor))
22 )
23
24# Convention: channel 1 corresponds to the next state prediction u(t2)
25u_t2_pred = pred_all[:, 1] # shape: (B, H, W)
26print(u_t2_pred.shape)
271from huggingface_hub import hf_hub_download
2import torch
3
4ckpt_path = hf_hub_download(
5 repo_id="saipuppala/diffusion_transformer ",
6 filename="diffusion_finetuned.pth",
7)
8
9state_dict = torch.load(ckpt_path, map_location="cpu")
10# then load into a PDETransformer instance as shown above
11
12u(t2) given [u(t0), u(t1)]