import com.mindspore.lite.LiteSession;
LiteSession defines session in MindSpore Lite for compiling Model and forwarding model.
public boolean init(MSConfig config)
Initialize LiteSession.
Parameters
MSConfig
: MSConfig class.Returns
Whether the initialization is successful.
public void bindThread(boolean if_bind)
Attempt to bind or unbind threads in the thread pool to or from the specified cpu core.
Parameters
if_bind
: Define whether to bind or unbind threads.public boolean compileGraph(Model model)
Compile MindSpore Lite model.
Parameters
Model
: Define the model to be compiled.Returns
Whether the compilation is successful.
public boolean runGraph()
Run the session for inference.
Returns
Whether the inference is successful.
public List<MSTensor> getInputs()
Get the MSTensors input of MindSpore Lite model.
Returns
The vector of MindSpore Lite MSTensor.
public MSTensor getInputsByTensorName(String tensorName)
Get the MSTensors input of MindSpore Lite model by the node name.
Parameters
tensorName
: Define the tensor name.Returns
MindSpore Lite MSTensor.
public List<MSTensor> getOutputsByNodeName(String nodeName)
Get the MSTensors output of MindSpore Lite model by the node name.
Parameters
nodeName
: Define the node name.Returns
The vector of MindSpore Lite MSTensor.
public Map<String, MSTensor> getOutputMapByTensor()
Get the MSTensors output of the MindSpore Lite model associated with the tensor name.
Returns
The map of output tensor name and MindSpore Lite MSTensor.
public List<String> getOutputTensorNames()
Get the name of output tensors of the model compiled by this session.
Returns
The vector of string as output tensor names in order.
public MSTensor getOutputByTensorName(String tensorName)
Get the MSTensors output of MindSpore Lite model by the tensor name.
Parameters
tensorName
: Define the tensor name.Returns
Pointer of MindSpore Lite MSTensor.
public boolean resize(List<MSTensor> inputs, int[][] dims)
Resize inputs shape.
Parameters
inputs
: Model inputs.dims
: Define the new inputs shape.Returns
Whether the resize is successful.
public void free()
Free LiteSession.
public boolean export(String modelFilename, int model_type, int quantization_type)
Export the model.
Parameters
modelFilename
: Model file name.model_type
: Train or Inference type.quantization_type
: The quant type.Returns
Whether the export is successful.
public void train()
Switch to the train mode
public void eval()
Switch to the eval mode.
public void isTrain()
It is Train mode.
public void isEval()
It is Eval mode.
public boolean setLearningRate(float learning_rate)
set learning rate.
Parameters
learning_rate
: learning rate.Returns
Whether the set learning rate is successful.
public boolean setupVirtualBatch(int virtualBatchMultiplier, float learningRate, float momentum)
Set the virtual batch.
Parameters
virtualBatchMultiplier
: virtual batch multuplier.learningRate
: learning rate.momentum
: monentum.Returns
Whether the virtual batch is successfully set.
public List<MSTensor> getFeaturesMap()
Get the FeatureMap.
Returns
FeaturesMap Tensor list.
public boolean updateFeatures(List<MSTensor> features)
Update model Features.
Parameters
features
: new FeatureMap Tensor List.Returns
Whether the model features is successfully update.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。