Model
Reflection-based parameter discovery, serialization, and deserialization for F# record models.
| Function | Description |
|---|---|
loadFromDict model tensors nameMap mode | Load tensors from a dictionary into the model, matching by parameter name. |
| When nameMap is Some, dictionary keys are translated before matching. | |
loadInto model filePath mode | Load tensors from a .safetensors file into the model in place. |
| Shape and dtype are validated from the header before any tensor data is read. | |
| Only the tensors that match both shape and dtype are loaded into memory. | |
namedParams model | Return all named tensors in the model via reflection. |
save model filePath | Save all model tensors to a .safetensors file. |
trainableVars model | Return all tensors that require gradients. |
loadFromDict
loadFromDict model tensors nameMap mode
Load tensors from a dictionary into the model, matching by parameter name. When nameMap is Some, dictionary keys are translated before matching.
Parameters
model:'Ttensors:Map<string, Tensor>nameMap:Map<string, string> optionmode:LoadMode
Returns LoadReport
loadInto
loadInto model filePath mode
Load tensors from a .safetensors file into the model in place. Shape and dtype are validated from the header before any tensor data is read. Only the tensors that match both shape and dtype are loaded into memory.
Parameters
model:'TfilePath:stringmode:LoadMode
Returns LoadReport
namedParams
namedParams model
Return all named tensors in the model via reflection.
Parameters
model:'T
Returns (string * Tensor) list
save
save model filePath
Save all model tensors to a .safetensors file.
Parameters
model:'TfilePath:string
trainableVars
trainableVars model
Return all tensors that require gradients.
Parameters
model:'T
Returns Tensor list