Documentation
¶
Overview ¶
Package model provides model serialization (save/load) for go-tensorflow, analogous to tf.keras.models.save_model / load_model.
Index ¶
- func BytesToFloat64(b [8]byte) float64
- func Float64ToBytes(f float64) [8]byte
- func LoadWeights(path string) ([]float64, error)
- func SaveCheckpoint(ckpt *Checkpoint, weights []float64, dir string) error
- func SaveConfig(config *ModelConfig, path string) error
- func SaveModel(config *ModelConfig, weights []float64, dir string) error
- func SaveWeights(weights []float64, path string) error
- type Checkpoint
- type LayerConfig
- type ModelConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BytesToFloat64 ¶
BytesToFloat64 converts 8 bytes to a float64.
func Float64ToBytes ¶
Float64ToBytes converts a float64 to its 8-byte binary representation.
func LoadWeights ¶
LoadWeights reads model weights from a binary file.
func SaveCheckpoint ¶
func SaveCheckpoint(ckpt *Checkpoint, weights []float64, dir string) error
SaveCheckpoint saves a checkpoint to disk.
func SaveConfig ¶
func SaveConfig(config *ModelConfig, path string) error
SaveConfig writes a model configuration to a JSON file.
func SaveModel ¶
func SaveModel(config *ModelConfig, weights []float64, dir string) error
SaveModel saves both config and weights to a directory.
func SaveWeights ¶
SaveWeights writes model weights to a binary file. Format: [uint64 count][float64 values...]
Types ¶
type Checkpoint ¶
type Checkpoint struct {
Epoch int `json:"epoch"`
Loss float64 `json:"loss"`
Weights string `json:"weights_file"`
}
Checkpoint saves a training checkpoint with epoch and loss info.
func LoadCheckpoint ¶
func LoadCheckpoint(path string) (*Checkpoint, error)
LoadCheckpoint loads a checkpoint from disk.
type LayerConfig ¶
LayerConfig describes a single layer's configuration for serialization.
type ModelConfig ¶
type ModelConfig struct {
Name string `json:"name"`
Version string `json:"version"`
Layers []LayerConfig `json:"layers"`
LearningRate float64 `json:"learning_rate,omitempty"`
LossFunction string `json:"loss_function,omitempty"`
}
ModelConfig describes the full model architecture for serialization.
func LoadConfig ¶
func LoadConfig(path string) (*ModelConfig, error)
LoadConfig reads a model configuration from a JSON file.