pth_catalogue: List the tensors in a PyTorch checkpoint

View source: R/pth.R

pth_catalogueR Documentation

List the tensors in a PyTorch checkpoint

Description

Reads the metadata of a .pth file — the tensor names, shapes and dtypes — without reading the tensors. A checkpoint is a zip holding one pickle of metadata and one entry per tensor, so the catalogue is cheap whatever the file weighs.

Usage

pth_catalogue(path)

Arguments

path

Path to a .pth file saved by torch.save().

Details

What comes back is the checkpoint's own state_dict order, which is the order the model's modules were built in.

Value

A data.frame with one row per tensor and the columns name, shape (as "a x b"), dtype, n (element count), bytes, and entry (the zip entry holding the data). The attribute "file" carries the path.

Examples

## Not run: 
cat <- pth_catalogue("model.pth")
head(cat)
sum(cat$n)          # total parameters

## End(Not run)

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