Skip to content

Instantly share code, notes, and snippets.

@confluentgist
Forked from kaiwaehner/inference.java
Created October 29, 2019 23:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save confluentgist/7d0b954153b3d5c5a323293ba9458fde to your computer and use it in GitHub Desktop.
Save confluentgist/7d0b954153b3d5c5a323293ba9458fde to your computer and use it in GitHub Desktop.
final KStream<String, String> inputEvents = builder.stream(inputTopic);
inputEvents.foreach((key, value) -> {
// Transform input values (list of Strings) to expected DL4J parameters (two Integer values):
String[] valuesAsArray = value.split(",");
INDArray input = Nd4j.create(Integer.parseInt(valuesAsArray[0]), Integer.parseInt(valuesAsArray[1]));
// Model inference in real time:
output = model.output(input);
prediction = output.toString();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment