Getting Started
Step-by-step guide to importing Keras models — saving in Python, loading in Java, and running inference
Getting Started with Keras Model Import
Prerequisites
Step 1: Save Your Keras Model in Python
Option A: Save the Full Model (Recommended)
model.save('my_model.h5')Option B: Save Architecture and Weights Separately
Option C: Architecture Only (No Weights)
Step 2: Add the Maven Dependency
Step 3: Load a Sequential Model as MultiLayerNetwork
Loading from a Full Model File
Loading from Separate Config and Weights Files
Loading Configuration Only (No Weights)
Step 4: Load a Functional API Model as ComputationGraph
Loading from a Full Model File
Loading from Separate Files
Step 5: Run Inference
MultiLayerNetwork Inference
ComputationGraph Inference
Step 6: Save the Imported Model
Complete Example: Sequential MLP
Common Issues
Training configuration not found
Unsupported layer
ClassPathResource not found
Next Steps
Last updated
Was this helpful?