import torch\n\
import torch.nn as nn\n\
\n\
model = nn.Sequential(\n\
nn.Linear(32,16),\n\
nn.ReLU(),\n\
nn.Linear(16,8),\n\
nn.ReLU()\n\
)\n\
\n\
criterion = nn.MSELoss()\n\
optimizer = torch.optim.SGD(model.parameters(),lr=0.01)\n\
\n\
x=torch.randn(2,32)\n\
y=torch.randn(2,8)\n\
\n\
for i in range(500):\n\
y_pred = model(x)\n\
loss = criterion(y_pred,y)\n\
optimizer.zero_grad()\n\
loss.backward()\n\
optimizer.step()\n\
\n\
model.eval()\n\
m = torch.jit.script(model)\n\
torch.jit.save(m,'PyTorchModel.pt')\n";
m.SaveSource(
"make_pytorch_model.py");
std::cout<<"\n\n";
std::cout<<"\n\n";
std::cout<<"\n\n";
std::cout<<"Shape of tensor \"0weight\": ";
std::cout<<it<<",";
}
std::cout<<"\n\nData type of tensor \"0weight\": ";
std::cout<<SOFIE::ConvertTypeToString(
tensorType);
std::cout<<"\n\n";
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TSystem * gSystem
void PrintIntermediateTensors()
bool CheckIfTensorAlreadyExist(std::string tensor_name)
void OutputGenerated(std::string filename="", bool append=false)
const ETensorType & GetTensorType(std::string name) const
const std::vector< size_t > & GetTensorShape(std::string name) const
void PrintInitializedTensors()
void Generate(std::underlying_type_t< Options > options, int batchSize=-1, long pos=0, bool verbose=false)
void PrintRequiredInputTensors()
static void PyInitialize()
Initialize Python interpreter.
Class supporting a collection of lines with C++ code.
virtual Int_t Exec(const char *shellcmd)
Execute a command.
TString Python_Executable()
Function to find current Python executable used by ROOT If "Python3" is installed,...