Class MLIntegrationExamples.TensorFlowAdapter
java.lang.Object
neqsim.process.safety.risk.ml.MLIntegrationExamples.BaseMLAdapter
neqsim.process.safety.risk.ml.MLIntegrationExamples.TensorFlowAdapter
- All Implemented Interfaces:
Serializable, MLIntegrationExamples.MLModelAdapter
- Enclosing class:
MLIntegrationExamples
public static class MLIntegrationExamples.TensorFlowAdapter
extends MLIntegrationExamples.BaseMLAdapter
Adapter for TensorFlow SavedModel format.
Loads TensorFlow models using the TensorFlow Java API.
Dependencies Required
<dependency> <groupId>org.tensorflow</groupId> <artifactId>tensorflow-core-platform</artifactId> <version>0.5.0</version> </dependency>
- Since:
- 3.3.0
- Version:
- 1.0
- Author:
- NeqSim Development Team
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Stringprivate Stringprivate static final longFields inherited from class MLIntegrationExamples.BaseMLAdapter
featureDefaults, inputFeatures, isLoaded, modelName -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class MLIntegrationExamples.BaseMLAdapter
getInputFeatures, getModelName, isLoaded, prepareInput
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
modelDir
-
inputTensorName
-
outputTensorName
-
-
Constructor Details
-
TensorFlowAdapter
public TensorFlowAdapter(String modelDir, List<String> inputFeatures, String inputTensorName, String outputTensorName) Creates a TensorFlow adapter.- Parameters:
modelDir- path to SavedModel directoryinputFeatures- input feature namesinputTensorName- name of input tensoroutputTensorName- name of output tensor
-
-
Method Details
-
load
public void load()Loads the TensorFlow model.In production:
model = SavedModelBundle.load(modelDir, "serve");
-
predict
Description copied from interface:MLIntegrationExamples.MLModelAdapterPredicts output from input features.- Parameters:
features- input features as name-value map- Returns:
- prediction score or probability
-