ag_state_dict: Model weights as plain R data

View source: R/ag_save.R

ag_state_dictR Documentation

Model weights as plain R data

Description

A copy of every parameter and persistent buffer (ag_batch_norm running statistics) as host matrices, keyed like model$parameters(). Values are R doubles whatever the device or ag_dtype(): an f32 value is represented exactly, so a state taken on the GPU in f32 restores on the CPU (or back) to the same numbers. f16/bf16 weights carry only their own precision; continuing exactly across f16 and f32 is not possible.

Usage

ag_state_dict(model)

Arguments

model

An ag_sequential, an ag_* layer, or anything with a parameters() or params() method.

Details

Use it for checkpoints, for copying weights between models (target networks: ag_load_state_dict(target, ag_state_dict(online))), or with saveRDS. As with any .rds, only read files you trust.

Value

A list with parameters, buffers and param_dtypes, plus format/version.

See Also

ag_load_state_dict, ag_save_model


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