/dpasca-pytorch-examples

Random testbed/scratchpad for simple experiments with LibTorch

Primary LanguageJupyter NotebookMIT LicenseMIT

dpasca-pytorch-examples

Overview

This is just a random testbed/scratchpad for simple experiments with LibTorch and PyTorch.

Setup (C++)

It's regularly only tested on macOS, but it should work on Linux and probably Windows.

Get LibTorch here. Select LibTorch or Source if you want to build from source.

The CMake build is currently looking for ../libtorch or ../pytorch-install (relative to the root of this repo). Change as necessary.

Build and Run (C++)

./build.sh

./_build/example*

"screenshots"

 1.1100000 |
 1.0000000 |                  *****                  *****                  ****
 0.8900000 |*                *     *                *     *               **    *
 0.7800000 | *              *       *              *       *             *       *
 0.6700000 |  *            *         *            *         *                     *
 0.5600000 |   *                      *          *                      *          *
 0.4500000 |    *         *                     *            *         *            *
 0.3400000 |     *       *             *       *              *       *              *
 0.2300000 |      *     *               *                      *     *
 0.1200000 |       *  **                 **  **                 ** **
 0.0100000 |        **                     **                     *
-0.1000000 |--------------------------------------------------------------------------

## Test Predictions
 1.0916607 |
 0.9902501 |                   ****                   ****                  *****
 0.8888394 |**                *    *                **    *                *     *
 0.7874287 |                 *      *                      *              *
 0.6860180 |  *             *        *             *                              *
 0.5846074 |   *           *          *           *         *            *         *
 0.4831967 |    *                                *           *          *           *
 0.3817860 |              *            *                      *        *
 0.2803754 |     **      *              *      **              *      *              *
 0.1789647 |       ** ***                *** **                 **  **
 0.0775540 |         *                      *                     **
-0.0238566 |--------------------------------------------------------------------------

## Train Loss
 0.3133923 |
 0.2825171 |
 0.2516420 |
 0.2207669 |
 0.1898918 |*
 0.1590166 |
 0.1281415 |  *
 0.0972664 | *
 0.0663913 |      *  *** ***
 0.0355161 |   *** **   *   **************************  ******************************
 0.0046410 |                                          **
-0.0262341 |--------------------------------------------------------------------------

## Test Loss
 0.1901521 |
 0.1715822 |
 0.1530123 |*
 0.1344424 |  *
 0.1158725 |
 0.0973026 | *
 0.0787328 |   *
 0.0601629 |    ** **       *   *
 0.0415930 |      *  ** *    *** ******* *   ** *** ****    * * *       *
 0.0230231 |           * ***            * ***  *   *    **** * *  ****** *************
 0.0044532 |                                                     *
-0.0141167 |--------------------------------------------------------------------------

Epoch [2120/10000], Train Loss: 0.0184644, Test Loss: 0.013449