examples
examples copied to clipboard
No matching function call error in custom_dataset example
Hi, An error occurs when attempting to compile the sample code in line
push_back(Functional(torch::log_softmax, 1, torch::nullopt));
And the error is
error: no matching function for call to 'torch::nn::Functional::Functional(<unresolved overloaded function type>, int, const c10::nullopt_t&)'
Am I missing something? I have used the same code in example.
The problem described here
The fast solution - specify exact type of overloaded function passed to Functional:
push_back(Functional(static_cast<torch::Tensor(&)(const torch::Tensor&, int64_t, torch::optional<torch::ScalarType> )>(torch::log_softmax), 1, torch::nullopt));
@soumith, @ShahriarSS, the above solution resolves this issue. Do you think this can be added as fix to the example?
@deepali-c The last time we were working on structures for functions like log_softmax
to replace torch::nn::Functional
's. I think they should be used here.
@smartnet-club would you like to contribute the fix?