finetuner.tailor.paddle package

Module contents

class finetuner.tailor.paddle.PaddleTailor(model, input_size=None, input_dtype='float32')[source]

Bases: finetuner.tailor.base.BaseTailor

Tailor class for Paddle DNN models.

Note

To use this class, you need to set input_size and input_dtype in __init__()

Tailor converts a general DNN model into an embedding model.

Parameters
  • model (AnyDNN) – a general DNN model

  • input_size (Optional[Tuple[int, …]]) – a sequence of integers defining the shape of the input tensor. Note, batch size is not part of input_size. It is required for PytorchTailor and PaddleTailor, but not C

  • input_dtype (str) – the data type of the input tensor.

summary(skip_identity_layer=False)[source]

Interpret the DNN model and produce model information.

Parameters

skip_identity_layer (bool) – If skip identity layer.

Return type

LayerInfoType

Returns

The model information stored as dict.

to_embedding_model(layer_name=None, output_dim=None, freeze=False)[source]

Convert a general model from model to an embedding model.

Parameters
  • layer_name (Optional[str]) – the name of the layer that is used for output embeddings. All layers after that layer will be removed. When set to None, then the last layer listed in embedding_layers will be used. To see all available names you can check name field of embedding_layers.

  • output_dim (Optional[int]) – the dimensionality of the embedding output.

  • freeze (bool) – if set, then freeze all weights of the original model.

Return type

AnyDNN

Returns

Converted embedding model.