pt_transformer_load: Build a piece transformer and load a checkpoint into it

View source: R/piece_transformer.R

pt_transformer_loadR Documentation

Build a piece transformer and load a checkpoint into it

Description

Reads a .pth saved by torch.save() and returns the model ready to run. Everything that differs between torch's conventions and this package's is resolved here rather than at inference time.

Usage

pt_transformer_load(path, layout = pt_cube4_layout(), ...)

Arguments

path

Path to the .pth checkpoint.

layout

A layout list; defaults to pt_cube4_layout.

...

Passed to pt_transformer — d_model, n_heads and the rest, when they differ from the defaults.

Value

A pt_transformer with the checkpoint's weights.

See Also

pth_catalogue to see what a checkpoint holds.

Examples

## Not run: 
model <- pt_transformer_load("model.pth")
q <- pt_forward(model, rep(0:5, each = 16))
which.max(q)

## End(Not run)

ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.