Learn R Programming

ggmlR (version 0.8.4)

pt_transformer_load: 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(), ...)

Value

A pt_transformer with the checkpoint's weights.

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.

See Also

pth_catalogue to see what a checkpoint holds.

Examples

Run this code
if (FALSE) {
model <- pt_transformer_load("model.pth")
q <- pt_forward(model, rep(0:5, each = 16))
which.max(q)
}

Run the code above in your browser using DataLab