examples icon indicating copy to clipboard operation
examples copied to clipboard

No matching function call error in custom_dataset example

Open blgnksy opened this issue 4 years ago • 4 comments

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.

blgnksy avatar Dec 15 '19 19:12 blgnksy

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));

smartnet-club avatar Jan 31 '20 12:01 smartnet-club

@soumith, @ShahriarSS, the above solution resolves this issue. Do you think this can be added as fix to the example?

deepali-c avatar Apr 16 '20 11:04 deepali-c

@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.

ShahriarRezghi avatar Apr 16 '20 22:04 ShahriarRezghi

@smartnet-club would you like to contribute the fix?

msaroufim avatar Mar 09 '22 23:03 msaroufim