# EncodeProto

public final class **EncodeProto** The op serializes protobuf messages provided in the input tensors.


The types of the tensors in \`values\` must match the schema for the fields
specified in \`field_names\`. All the tensors in \`values\` must have a common
shape prefix, *batch_shape*.


The \`sizes\` tensor specifies repeat counts for each field. The repeat count
(last dimension) of a each tensor in \`values\` must be greater than or equal
to corresponding repeat count in \`sizes\`.


A \`message_type\` name must be provided to give context for the field names.
The actual message descriptor can be looked up either in the linked-in
descriptor pool or a filename provided by the caller using the
\`descriptor_source\` attribute.


For the most part, the mapping between Proto field types and TensorFlow dtypes
is straightforward. However, there are a few special cases:


- A proto field that contains a submessage or group can only be converted
to \`DT_STRING\` (the serialized submessage). This is to reduce the complexity
of the API. The resulting string can be used as input to another instance of
the decode_proto op.


- TensorFlow lacks support for unsigned integers. The ops represent uint64
types as a \`DT_INT64\` with the same twos-complement bit pattern (the obvious
way). Unsigned int32 values can be represented exactly by specifying type
\`DT_INT64\`, or using twos-complement if the caller specifies \`DT_INT32\` in
the \`output_types\` attribute.


The \`descriptor_source\` attribute selects the source of protocol
descriptors to consult when looking up \`message_type\`. This may be:


- An empty string or "local://", in which case protocol descriptors are
created for C++ (not Python) proto definitions linked to the binary.


- A file, in which case protocol descriptors are created from the file,
which is expected to contain a \`FileDescriptorSet\` serialized as a string.
NOTE: You can build a \`descriptor_source\` file using the \`--descriptor_set_out\`
and \`--include_imports\` options to the protocol compiler \`protoc\`.


- A "bytes://", in which protocol descriptors are created from \`\`, which is expected to be a \`FileDescriptorSet\` serialized as a string.

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

### Nested Classes

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

### Public Methods

|---|---|
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<String\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto#asOutput())() Returns the symbolic handle of a tensor. |
| [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<String\> | [bytes](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto#bytes())() Tensor of serialized protos with shape \`batch_shape\`. |
| static [EncodeProto](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto) | [create](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand<java.lang.Integer>,%20java.lang.Iterable<org.tensorflow.Operand<?>>,%20java.util.List<java.lang.String>,%20java.lang.String,%20org.tensorflow.op.core.EncodeProto.Options...))([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<Integer\> sizes, Iterable\<[Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<?\>\> values, List\<String\> fieldNames, String messageType, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto.Options) options) Factory method to create a class wrapping a new EncodeProto operation. |
| static [EncodeProto.Options](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto.Options) | [descriptorSource](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto#descriptorSource(java.lang.String))(String descriptorSource) |

### 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() |

From interface [org.tensorflow.Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)

|---|---|
| abstract [Output](https://www.tensorflow.org/api_docs/java/org/tensorflow/Output)\<String\> | [asOutput](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand#asOutput())() Returns the symbolic handle of a tensor. |

## Public Methods

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

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
used to obtain a symbolic handle that represents the computation of the input.

<br />

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

Tensor of serialized protos with shape \`batch_shape\`.

#### public static [EncodeProto](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto)
**create**
([Scope](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<Integer\> sizes, Iterable\<[Operand](https://www.tensorflow.org/api_docs/java/org/tensorflow/Operand)\<?\>\> values, List\<String\> fieldNames, String messageType, [Options...](https://www.tensorflow.org/api_docs/java/org/tensorflow/op/core/EncodeProto.Options) options)

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

##### Parameters

| scope | current scope |
| sizes | Tensor of int32 with shape \`\[batch_shape, len(field_names)\]\`. |
| values | List of tensors containing values for the corresponding field. |
| fieldNames | List of strings containing proto field names. |
| messageType | Name of the proto message type to decode. |
| options | carries optional attributes values |
|---|---|

##### Returns

- a new instance of EncodeProto

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

<br />