Skip to content

Maverobot/libtorch_examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libtorch_examples

Examples using libtorch, the C++ frontend of PyTorch (v2.5.1).

Examples

Example Description
hello_world.cpp Tensor creation, reshaping, and transpose operations
simple_optimization_example.cpp Gradient descent — manual and with torch::optim::SGD
function_approx.cpp Feedforward network that learns y = cos(x)
time_serie_prediction.cpp LSTM-based time series forward pass
lstm_example.cpp Bidirectional LSTM trained on a simple sequence
dataset_example.cpp Custom dataset with CSV parsing and one-hot encoding

Requirements

  • CMake ≥ 3.14
  • C++17 compiler

libtorch is downloaded automatically during the CMake configure step if not found locally.

Compilation

Download libtorch automatically:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build .

Use an existing local libtorch:

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch && cmake --build .

About

Examples of libtorch, which is C++ front end of PyTorch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors