本文整理汇总了Java中org.tensorflow.contrib.android.TensorFlowInferenceInterface.initializeTensorFlow方法的典型用法代码示例。如果您正苦于以下问题:Java TensorFlowInferenceInterface.initializeTensorFlow方法的具体用法?Java TensorFlowInferenceInterface.initializeTensorFlow怎么用?Java TensorFlowInferenceInterface.initializeTensorFlow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.tensorflow.contrib.android.TensorFlowInferenceInterface
的用法示例。
在下文中一共展示了TensorFlowInferenceInterface.initializeTensorFlow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import org.tensorflow.contrib.android.TensorFlowInferenceInterface; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bufferSize = AudioRecord.getMinBufferSize(16000,
AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);
setButtonHandlers();
enableButtons(false);
inferenceInterface = new TensorFlowInferenceInterface();
inferenceInterface.initializeTensorFlow(getAssets(), MODEL_FILE);
// tensorFlowSample();
}
示例2: tensorFlowSample
import org.tensorflow.contrib.android.TensorFlowInferenceInterface; //导入方法依赖的package包/类
public void tensorFlowSample(){
float num1 = 0.0f;
float num2 = 3.33f;
float num3 = 1.2f;
String MODEL_FILE = "file:///android_asset/optimized_tfdroid2.pb";
String INPUT_NODE = "I";
String OUTPUT_NODE = "O";
int[] INPUT_SIZE = {1,3};
inferenceInterface = new TensorFlowInferenceInterface();
inferenceInterface.initializeTensorFlow(getAssets(), MODEL_FILE);
float[] inputFloats = {num1, num2, num3};
inferenceInterface.fillNodeFloat(INPUT_NODE, INPUT_SIZE, inputFloats);
inferenceInterface.runInference(new String[] {OUTPUT_NODE});
float[] resu = new float[2];
inferenceInterface.readNodeFloat(OUTPUT_NODE, resu);
Log.v("output_mode" , Arrays.toString(resu));
}
示例3: InitSession
import org.tensorflow.contrib.android.TensorFlowInferenceInterface; //导入方法依赖的package包/类
TensorFlowInferenceInterface InitSession(){
inferenceInterface = new TensorFlowInferenceInterface();
inferenceInterface.initializeTensorFlow(getActivity().getAssets(), MODEL_FILE);
OutputNodes = LoadFile(OUTPUT_NODES);
WORD_MAP = LoadFile("idmap");
return inferenceInterface;
}
示例4: onCreate
import org.tensorflow.contrib.android.TensorFlowInferenceInterface; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
inferenceInterface = new TensorFlowInferenceInterface();
inferenceInterface.initializeTensorFlow(getAssets(), MODEL_FILE);
final Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
final EditText editNum1 = (EditText) findViewById(R.id.editNum1);
final EditText editNum2 = (EditText) findViewById(R.id.editNum2);
final EditText editNum3 = (EditText) findViewById(R.id.editNum3);
float num1 = Float.parseFloat(editNum1.getText().toString());
float num2 = Float.parseFloat(editNum2.getText().toString());
float num3 = Float.parseFloat(editNum3.getText().toString());
float[] inputFloats = {num1, num2, num3};
inferenceInterface.fillNodeFloat(INPUT_NODE, INPUT_SIZE, inputFloats);
inferenceInterface.runInference(new String[] {OUTPUT_NODE});
float[] resu = {0, 0};
inferenceInterface.readNodeFloat(OUTPUT_NODE, resu);
final TextView textViewR = (TextView) findViewById(R.id.txtViewResult);
textViewR.setText(Float.toString(resu[0]) + ", " + Float.toString(resu[1]));
}
});
}