Hi there,
I’m trying to make a chatbot for C++ with PyTorch however I’m having a hard time figuring out how to convert some code originally from a python PyTorch tutorial I found here
More specifically my problem is with “data[‘input_size’], data[‘hidden_size’]”, etc. because I have created the torch::jit::module (Which from what I can tell is how you load the model) from a Visual Studio .pth resource file that was created in python.
I loaded the pth resource compiled into the actual executable like this btw:
#include <resource.h>
#include <Windows.h>
#include <pytorch/torch/script.h>
#include <string>
#include <sstream>
HMODULE GCM()
{
HMODULE hModule = NULL;
GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)GCM, &hModule);
return hModule;
}
torch::jit::Module Load_Compiled_PyTorch_Model(int resource)
{
HRSRC hRes = FindResource(GCM(), MAKEINTRESOURCE(resource), L"PTH");
std::stringstream result_stream;
result_stream << hRes;
torch::jit::Module hFinal = torch::jit::load(result_stream);
return hFinal;
}
Anyways I need to figure out the C++ equivalent way to do data['input_size']
and so on
And I’m also kinda wondering if the way I loaded the torch model as a visual studio resource will work or if I need to do that differently.
Thanks in advance.