# Batch

public final class **Batch** Batches all input tensors nondeterministically.


When many instances of this Op are being run concurrently with the same
container/shared_name in the same device, some will output zero-shaped Tensors
and others will output Tensors of size up to max_batch_size.


All Tensors in in_tensors are batched together (so, for example, labels and
features should be batched with a single instance of this operation.


Each invocation of batch emits an \`id\` scalar which will be used to identify
this particular invocation when doing unbatch or its gradient.


Each op which emits a non-empty batch will also emit a non-empty batch_index
Tensor, which, is a \[K, 3\] matrix where each row contains the invocation's id,
start, and length of elements of each set of Tensors present in batched_tensors.


Batched tensors are concatenated along the first dimension, and all tensors in
in_tensors must have the first dimension of the same size.


in_tensors: The tensors to be batched.
num_batch_threads: Number of scheduling threads for processing batches of work.
Determines the number of batches processed in parallel.
max_batch_size: Batch sizes will never be bigger than this.
batch_timeout_micros: Maximum number of microseconds to wait before outputting
an incomplete batch.
allowed_batch_sizes: Optional list of allowed batch sizes. If left empty, does
nothing. Otherwise, supplies a list of batch sizes, causing the op to pad
batches up to one of those sizes. The entries must increase monotonically, and
the final entry must equal max_batch_size.
grad_timeout_micros: The timeout to use for the gradient. See Unbatch.
batched_tensors: Either empty tensors or a batch of concatenated Tensors.
batch_index: If out_tensors is non-empty, has information to invert it.
container: Controls the scope of sharing of this batch.
id: always contains a scalar with a unique ID for this invocation of Batch.
shared_name: Concurrently running instances of batch in the same device with the
same container and shared_name will batch their elements together. If left
empty, the op name will be used as the shared name.
T: the types of tensors to be batched.

<br />

<br />

<br />

<br />

<br />

<br />

### Nested Classes

|---|---|---|---|
| class | [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) || Optional attributes for `https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch` |

### Public Methods

|---|---|
| static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) | [allowedBatchSizes](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#allowedBatchSizes(java.util.List<java.lang.Long>))(List\<Long\> allowedBatchSizes) |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Long\> | [batchIndex](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#batchIndex())() |
| List\<[Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<?\>\> | [batchedTensors](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#batchedTensors())() |
| static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) | [batchingQueue](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#batchingQueue(java.lang.String))(String batchingQueue) |
| static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) | [container](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#container(java.lang.String))(String container) |
| static [Batch](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch) | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#create(org.tensorflow.op.Scope,%20java.lang.Iterable<org.tensorflow.Operand<?>>,%20java.lang.Long,%20java.lang.Long,%20java.lang.Long,%20java.lang.Long,%20org.tensorflow.op.core.Batch.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, Iterable\<[Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<?\>\> inTensors, Long numBatchThreads, Long maxBatchSize, Long batchTimeoutMicros, Long gradTimeoutMicros, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) options) Factory method to create a class wrapping a new Batch operation. |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Long\> | [id](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#id())() |
| static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) | [maxEnqueuedBatches](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#maxEnqueuedBatches(java.lang.Long))(Long maxEnqueuedBatches) |
| static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) | [sharedName](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch#sharedName(java.lang.String))(String sharedName) |

### Inherited Methods

From class [org.tensorflow.op.PrimitiveOp](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp)

|---|---|
| final boolean | [equals](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |
| final int | [hashCode](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |
| [Operation](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation) | [op](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying `https://www.tensorflow.org/api_docs/java/org/tensorflow/Operation` |
| final String | [toString](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |

From class java.lang.Object

|---|---|
| boolean | equals(Object arg0) |
| final Class\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| String | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options)
**allowedBatchSizes**
(List\<Long\> allowedBatchSizes)

<br />

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Long\>
**batchIndex**
()

<br />

#### public List\<[Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<?\>\>
**batchedTensors**
()

<br />

#### public static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options)
**batchingQueue**
(String batchingQueue)

<br />

#### public static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options)
**container**
(String container)

<br />

#### public static [Batch](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch)
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, Iterable\<[Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<?\>\> inTensors, Long numBatchThreads, Long maxBatchSize, Long batchTimeoutMicros, Long gradTimeoutMicros, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options) options)

Factory method to create a class wrapping a new Batch operation.

##### Parameters

| scope | current scope |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of Batch

#### public [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<Long\>
**id**
()

<br />

#### public static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options)
**maxEnqueuedBatches**
(Long maxEnqueuedBatches)

<br />

#### public static [Batch.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/Batch.Options)
**sharedName**
(String sharedName)

<br />