deepcarskit.model

class deepcarskit.model.context_recommender.ContextRecommender(config, dataset)

Bases: recbole.model.abstract_recommender.AbstractRecommender

This is a abstract context-aware recommender. All the context-aware model should implement this class. The base context-aware recommender class provide the basic embedding function of feature fields which also contains a first-order part of feature fields.

concat_embed_input_fields(interaction)
double_tower_embed_input_fields(interaction)

Embed the whole feature columns in a double tower way.

Args:

interaction (Interaction): The input data collection.

Returns:

torch.FloatTensor: The embedding tensor of token sequence columns in the first part. torch.FloatTensor: The embedding tensor of float sequence columns in the first part. torch.FloatTensor: The embedding tensor of token sequence columns in the second part. torch.FloatTensor: The embedding tensor of float sequence columns in the second part.

embed_float_fields(float_fields, embed=True)

Embed the float feature columns

Args:

float_fields (torch.FloatTensor): The input dense tensor. shape of [batch_size, num_float_field] embed (bool): Return the embedding of columns or just the columns itself. Defaults to True.

Returns:

torch.FloatTensor: The result embedding tensor of float columns.

embed_input_fields(interaction)

Embed the whole feature columns.

Args:

interaction (Interaction): The input data collection.

Returns:

torch.FloatTensor: The embedding tensor of token sequence columns. torch.FloatTensor: The embedding tensor of float sequence columns.

embed_token_fields(token_fields)

Embed the token feature columns

Args:

token_fields (torch.LongTensor): The input tensor. shape of [batch_size, num_token_field]

Returns:

torch.FloatTensor: The result embedding tensor of token columns.

embed_token_seq_fields(token_seq_fields, mode='mean')

Embed the token feature columns

Args:

token_seq_fields (torch.LongTensor): The input tensor. shape of [batch_size, seq_len] mode (str): How to aggregate the embedding of feature in this field. default=mean

Returns:

torch.FloatTensor: The result embedding tensor of token sequence columns.

getContextSituationDict(interaction, context_dims)
getContextSituationList(interaction, context_dims)
input_type = 1
training: bool
type = 3

deepcarskit.model.layers

Common Layers in recommender system

class deepcarskit.model.layers.FMFirstOrderLinear(config, dataset, output_dim=1)

Bases: recbole.model.layers.FMFirstOrderLinear

Calculate the first order score of the input features. This class is a member of ContextRecommender, you can call it easily when inherit ContextRecommender.

training: bool