Create Batch with Java API


Hello, currently, I implemented a fit and predict method for my neural network using the JAVA API. It works fine, however, I can only feed it 1 input and get 1 output at the time. I want to upgrade this to use a batch, however I am not sure how to proceed. The plan is to write a predict method with input float [][] state as an upgrade to the current method. What is the best way to do this?

When you define your neural net you should ensure the input placeholders are of the form [batch_size, num_features] for tabular problems, [batch_size, height, width, channels] for images, or [batch_size, sequence_length, num_features] for sequential problems like text, and that the outputs have a shape which includes batch_size. TF-Java can’t automatically add a batch dimension for you with the current low level API.

Thankful for the little by little useful exercise. Has conclusively the ordinary impact!