crslab.model.recommendation.gru4rec package

Submodules

GRU4REC

References

Hidasi, Balázs, et al. “Session-Based Recommendations with Recurrent Neural Networks.” in ICLR 2016.

class crslab.model.recommendation.gru4rec.gru4rec.GRU4RECModel(opt, device, vocab, side_data)[source]

Bases: crslab.model.base.BaseModel

item_size

A integer indicating the number of items.

hidden_size

A integer indicating the hidden state size in GRU.

num_layers

A integer indicating the number of GRU layers.

dropout_hidden

A float indicating the dropout rate to dropout hidden state.

dropout_input

A integer indicating if we dropout the input of model.

embedding_dim

A integer indicating the dimension of item embedding.

batch_size

A integer indicating the batch size.

Parameters
  • opt (dict) – A dictionary record the hyper parameters.

  • device (torch.device) – A variable indicating which device to place the data and model.

  • vocab (dict) – A dictionary record the vocabulary information.

  • side_data (dict) – A dictionary record the side data.

build_model()[source]

build model

cross_entropy(seq_out, pos_ids, neg_ids, input_mask)[source]
forward(batch, mode)[source]
Parameters
  • input_ids – padding in left, [pad, pad, id1, id2, …, idn]

  • target_ids – padding in left, [pad, pad, id2, id3, …, y]

reconstruct_input(input_ids)[source]

convert the padding from left to right

Module contents