我有以下java代码:
try (OrtEnvironment env = OrtEnvironment.getEnvironment();
OrtSession.SessionOptions opts = new OrtSession.SessionOptions()) {
opts.setOptimizationLevel(OrtSession.SessionOptions.OptLevel.BASIC_OPT);
try (OrtSession session = env.createSession("model.onnx", opts)) {
OnnxTensor.createTensor(env, 10.0f);
}
}
我想创建一个浮点值的 OnnxTensor。我收到以下异常:
Exception in thread "main" ai.onnxruntime.OrtException: Cannot convert class java.lang.Float to an OnnxTensor.
at ai.onnxruntime.TensorInfo.constructFromJavaArray(TensorInfo.java:208)
at ai.onnxruntime.OnnxTensor.createTensor(OnnxTensor.java:330)
at ai.onnxruntime.OnnxTensor.createTensor(OnnxTensor.java:314)