Shortcuts

Class LSTMImpl

Inheritance Relationships

Base Type

Class Documentation

class torch::nn::LSTMImpl : public torch::nn::detail::RNNImplBase<LSTMImpl>

A multi-layer long-short-term-memory (LSTM) module.

See https://pytorch.org/docs/master/nn.html#torch.nn.LSTM to learn about the exact behavior of this module.

See the documentation for torch::nn::LSTMOptions class to learn what constructor arguments are supported for this module.

Example:

LSTM model(LSTMOptions(2, 4).num_layers(3).batch_first(false).bidirectional(true));

Public Functions

LSTMImpl(int64_t input_size, int64_t hidden_size)
LSTMImpl(const LSTMOptions &options_)
std::tuple<Tensor, std::tuple<Tensor, Tensor>> forward(const Tensor &input, torch::optional<std::tuple<Tensor, Tensor>> hx_opt = {})
std::tuple<torch::nn::utils::rnn::PackedSequence, std::tuple<Tensor, Tensor>> forward_with_packed_input(const torch::nn::utils::rnn::PackedSequence &packed_input, torch::optional<std::tuple<Tensor, Tensor>> hx_opt = {})

Public Members

LSTMOptions options

Protected Functions

bool _forward_has_default_args() override

The following three functions allow a module with default arguments in its forward method to be used in a Sequential module.

You should NEVER override these functions manually. Instead, you should use the FORWARD_HAS_DEFAULT_ARGS macro.

unsigned int _forward_num_required_args() override
std::vector<torch::nn::AnyValue> _forward_populate_default_args(std::vector<torch::nn::AnyValue> &&arguments) override
void check_forward_args(const Tensor &input, std::tuple<Tensor, Tensor> hidden, const Tensor &batch_sizes) const
std::tuple<int64_t, int64_t, int64_t> get_expected_cell_size(const Tensor &input, const Tensor &batch_sizes) const
std::tuple<Tensor, Tensor> permute_hidden(std::tuple<Tensor, Tensor> hx, const Tensor &permutation) const
std::tuple<Tensor, std::tuple<Tensor, Tensor>> forward_helper(const Tensor &input, const Tensor &batch_sizes, const Tensor &sorted_indices, int64_t max_batch_size, torch::optional<std::tuple<Tensor, Tensor>> hx_opt)

Friends

friend struct torch::nn::AnyModuleHolder

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources