Wenbo_MA
(Wenbo Ma)
March 13, 2019, 8:18am
1
I’ve been trying to deploy my model in the form of a desktop application and I’ve successfully loaded my trained model in the C++ frontend. But I don’t know how to build my own dataset using C++ API. The tutorial only demonstrates how to load MNIST dataset. Dose anyone know how to do this?
Thanks in advance.
smth
March 13, 2019, 8:50am
2
Creating a C++ dataset is similar to creating a PyTorch python dataset.
One has to subclass the Dataset class, and then implement some base methods.
See the MNIST class for example:
#pragma once
#include <torch/data/datasets/base.h>
#include <torch/data/example.h>
#include <torch/types.h>
#include <torch/csrc/WindowsTorchApiMacro.h>
#include <cstddef>
#include <string>
namespace torch {
namespace data {
namespace datasets {
/// The MNIST dataset.
class TORCH_API MNIST : public Dataset<MNIST> {
public:
/// The mode in which the dataset is loaded.
enum class Mode { kTrain, kTest };
This file has been truncated. show original
Alternatively, you can subclass from BatchDataset and implement a get_batch
method that returns a batch of samples directly: https://github.com/pytorch/pytorch/blob/master/torch/csrc/api/include/torch/data/datasets/base.h#L40-L94
Wenbo_MA
(Wenbo Ma)
March 20, 2019, 7:28am
3
I’ll look into that. Thanks a lot!