jina.executors.encoders

class jina.executors.encoders.BaseEncoder(*args, **kwargs)[source]

Bases: jina.executors.BaseExecutor

BaseEncoder encodes chunk into vector representation.

The key function is encode().

encode(data, *args, **kwargs)[source]

Encode the data, needs to be implemented in subclass. :type data: Any :param data: the data to be encoded :param args: additional positional arguments :param kwargs: additional key-value arguments

Return type

EncodingType

class jina.executors.encoders.BaseNumericEncoder(*args, **kwargs)[source]

Bases: jina.executors.encoders.BaseEncoder

BaseNumericEncoder encodes data from a ndarray, potentially B x ([T] x D) into a ndarray of B x D

encode(data, *args, **kwargs)[source]
Parameters
  • data (np.ndarray) – a B x ([T] x D) numpy ndarray, B is the size of the batch

  • args – additional positional arguments

  • kwargs – additional key-value arguments

Return type

EncodingType

class jina.executors.encoders.BaseImageEncoder(*args, **kwargs)[source]

Bases: jina.executors.encoders.BaseNumericEncoder

BaseImageEncoder encodes data from a ndarray, potentially B x (Height x Width) into a ndarray of B x D

class jina.executors.encoders.BaseVideoEncoder(*args, **kwargs)[source]

Bases: jina.executors.encoders.BaseNumericEncoder

BaseVideoEncoder encodes data from a ndarray, potentially B x (Time x Height x Width) into a ndarray of B x D

class jina.executors.encoders.BaseAudioEncoder(*args, **kwargs)[source]

Bases: jina.executors.encoders.BaseNumericEncoder

BaseAudioEncoder encodes data from a ndarray, potentially B x (Time x D) into a ndarray of B x D

class jina.executors.encoders.BaseTextEncoder(*args, **kwargs)[source]

Bases: jina.executors.encoders.BaseEncoder

BaseTextEncoder encodes data from an array of string type (data.dtype.kind == ‘U’) of size B into a ndarray of B x D.

encode(data, *args, **kwargs)[source]
Parameters
  • data (np.ndarray) – an 1d array of string type (data.dtype.kind == ‘U’) in size B

  • args – additional positional arguments

  • kwargs – additional key-value arguments

Return type

EncodingType