Serialization
Saving and loading SameDiff graphs in FlatBuffers format
Saving a SameDiff Graph
save()
import org.nd4j.autodiff.samediff.SameDiff;
import java.io.File;
// Save with updater state (for resuming training)
sd.save(new File("model.fb"), true);
// Save without updater state (smaller file, for inference only)
sd.save(new File("model.fb"), false);asFlatGraph()
import java.nio.ByteBuffer;
ByteBuffer buffer = sd.asFlatGraph(true); // true = include updater stateasFlatPrint()
Loading a SameDiff Graph
load()
fromFlatGraph()
What Gets Saved
Component
Saved
Notes
Training Checkpoints
Interop with Model Import
File Format Details
Best Practices
SDNB and SDZ Formats (ADR 0035)
Format Overview
Format
Extension
Description
Best For
SDNB Format
SDZ Format
Sharding for Large Models (>2 GB)
Format Auto-Detection
Metadata
Key
Meaning
When to Use Each Format
Scenario
Recommended Format
Backward Compatibility
Last updated
Was this helpful?