Skip to content

Instantly share code, notes, and snippets.

@miquelbeltran
Created August 31, 2018 12:02
Show Gist options
  • Save miquelbeltran/6a29ab2fd2f70fe162985c8ac0c5c5a5 to your computer and use it in GitHub Desktop.
Save miquelbeltran/6a29ab2fd2f70fe162985c8ac0c5c5a5 to your computer and use it in GitHub Desktop.
// Pass the input data, as an array, that contains a single float array, with a single value
// So in all [0][0] = 21, a 1x1 matrix in the form a Array of FloatArray
val inp = arrayOf(floatArrayOf(21f))
val inputs = FirebaseModelInputs.Builder().add(inp).build()
// Run the model
interpreter.run(inputs, dataOptions)
.continueWith { task ->
try {
// The output is also a Array of FloatArray
val output = task.result.getOutput<Array<FloatArray>>(0)
// Result is in [0][0]
Log.d("MainActivity", "Multiplication result: ${output[0][0]}")
} catch (t: Throwable) {
Log.e("MainActivity", t.localizedMessage, t)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment