Skip to content
Snippets Groups Projects
Commit bfd53a17 authored by Franck Dary's avatar Franck Dary
Browse files

Updated syntax for pytorch 1.5

parent b43d29d9
No related branches found
No related tags found
No related merge requests found
......@@ -101,7 +101,7 @@ void Classifier::initNeuralNetwork(const std::vector<std::string> & definition)
if (splited.size() != 6 or (splited.back() != "false" and splited.back() != "true"))
util::myThrow(expected);
optimizer.reset(new torch::optim::Adam(getNN()->parameters(), torch::optim::AdamOptions(std::stof(splited[0])).amsgrad(splited.back() == "true").beta1(std::stof(splited[1])).beta2(std::stof(splited[2])).eps(std::stof(splited[3])).weight_decay(std::stof(splited[4]))));
optimizer.reset(new torch::optim::Adam(getNN()->parameters(), torch::optim::AdamOptions(std::stof(splited[0])).amsgrad(splited.back() == "true").betas({std::stof(splited[1]),std::stof(splited[2])}).eps(std::stof(splited[3])).weight_decay(std::stof(splited[4]))));
}
else
util::myThrow(expected);
......
......@@ -5,7 +5,7 @@ LSTMImpl::LSTMImpl(int inputSize, int outputSize, LSTMOptions options) : outputA
auto lstmOptions = torch::nn::LSTMOptions(inputSize, outputSize)
.batch_first(std::get<0>(options))
.bidirectional(std::get<1>(options))
.layers(std::get<2>(options))
.num_layers(std::get<2>(options))
.dropout(std::get<3>(options));
lstm = register_module("lstm", torch::nn::LSTM(lstmOptions));
......@@ -13,7 +13,7 @@ LSTMImpl::LSTMImpl(int inputSize, int outputSize, LSTMOptions options) : outputA
torch::Tensor LSTMImpl::forward(torch::Tensor input)
{
auto lstmOut = lstm(input).output;
auto lstmOut = std::get<0>(lstm(input));
if (outputAll)
return lstmOut.reshape({lstmOut.size(0), -1});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment