text
stringlengths
24
1.04M
metadata
stringlengths
233
497
### File: cmake/fetch_imagenette.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) function(fetch_imagenette DATA_DIR) set(IMAGENETTE_DIR "${DATA_DIR}/imagenette2-160") set(IMAGENETTE_DOWNLOAD_DIR "${DATA_DIR}/imagenette_download") set(IMAGENETTE_DATA_URL "https://s3.amazonaws.com/fast-ai-ima...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/fetch_imagenette.cmake", "license": "mit", "size": 1066}
### File: cmake/fetch_libtorch.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) include(FetchContent) set(CUDA_V "none" CACHE STRING "Determines libtorch CUDA version to download (11.8, 12.1 or none).") if(${CUDA_V} STREQUAL "none") set(LIBTORCH_DEVICE "cpu") elseif(${CUDA_V} STREQUAL "11.8") set(LIBTO...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/fetch_libtorch.cmake", "license": "mit", "size": 2506}
### File: cmake/fetch_mnist.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) function(fetch_mnist DATA_DIR) set(MNIST_DOWNLOAD_DIR "${DATA_DIR}/mnist/download") set(MNIST_DIR "${DATA_DIR}/mnist") set(MNIST_URL "https://ossci-datasets.s3.amazonaws.com/mnist") set(MNIST_EXTRACTED_FILES "t1...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/fetch_mnist.cmake", "license": "mit", "size": 1931}
### File: cmake/fetch_neural_style_transfer_images.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) function(fetch_neural_style_transfer_imagers DATA_DIR) set(NEURAL_STYLE_TRANSFER_IMAGES_DIR "${DATA_DIR}/neural_style_transfer_images") set(NEURAL_STYLE_TRANSFER_IMAGES_URL "https://github....
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/fetch_neural_style_transfer_images.cmake", "license": "mit", "size": 1487}
### File: cmake/fetch_penntreebank.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) function(fetch_penntreebank DATA_DIR) set(PENNTREEBANK_DIR "${DATA_DIR}/penntreebank") set(PENNTREEBANK_DOWNLOAD_NAME "train.txt") set(PENNTREEBANK_URL "https://raw.githubusercontent.com/wojzaremba/lstm/master...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/fetch_penntreebank.cmake", "license": "mit", "size": 895}
### File: cmake/find_gz_extractor.cmake cmake_minimum_required(VERSION 3.14 FATAL_ERROR) # Find program that can extract .gz files. # Based on: https://github.com/Amber-MD/cmake-buildscripts/blob/master/gzip.cmake find_program(7ZIP_EXECUTABLE 7z 7za DOC "Path to 7zip executable") find_program(GZIP_EXECUTABLE gzip DOC ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "cmake/find_gz_extractor.cmake", "license": "mit", "size": 839}
### File: docker/docker-entrypoint.sh #!/usr/bin/env bash set -Eeo pipefail cmake -B build -D CMAKE_BUILD_TYPE=Release \ -D CMAKE_PREFIX_PATH=/opt/conda/lib/python${PYTHON_VERSION}/site-packages/torch/share/cmake/Torch/ \ -D CREATE_SCRIPTMODULES=ON case $1 in basics|intermediate|advanced|popular) ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Shell", "repo_name": "minhanghuang/pytorch-cpp", "path": "docker/docker-entrypoint.sh", "license": "mit", "size": 865}
### File: main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> int main() { std::cout << "Welcome to PyTorch Tutorial in C++ for Deep Learning Researchers" << std::endl; }
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "main.cpp", "license": "mit", "size": 205}
### File: notebooks/pytorch_cpp_colab_notebook.ipynb { "cells": [ { "cell_type": "markdown", "metadata": { "id": "VS2lCrJC55PX" }, "source": [ "\n", "![Pytorch Cpp](https://github.com/prabhuomkar/pytorch-cpp/raw/master/images/pytorch_cpp.png)\n", "\n", ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Jupyter Notebook", "repo_name": "minhanghuang/pytorch-cpp", "path": "notebooks/pytorch_cpp_colab_notebook.ipynb", "license": "mit", "size": 30613}
### File: notebooks/tensor_slicing.ipynb { "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "cling::DynamicLibraryManager::loadLibrary(): dlopen(/Users/prabhuomkar/Projects/PyTorch/flare/li...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Jupyter Notebook", "repo_name": "minhanghuang/pytorch-cpp", "path": "notebooks/tensor_slicing.ipynb", "license": "mit", "size": 11537}
### File: tutorials/advanced/generative_adversarial_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(generative-adversarial-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME generative-adversarial-network) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIV...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/generative_adversarial_network/CMakeLists.txt", "license": "mit", "size": 980}
### File: tutorials/advanced/generative_adversarial_network/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "image_io.h" using image_io::save_image; int main() { std::cout << "Generative Adversarial Network\n\n"; // Device au...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/generative_adversarial_network/main.cpp", "license": "mit", "size": 6318}
### File: tutorials/advanced/image_captioning/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(image-captioning VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME image-captioning) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/CMakeLists.txt", "license": "mit", "size": 2309}
### File: tutorials/advanced/image_captioning/include/caption_dataset.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/data/datasets/base.h> #include <torch/data/example.h> #include <torch/types.h> #include <cstddef> #include <fstream> #include <string> #include <vector> #include "vocabular...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/caption_dataset.h", "license": "mit", "size": 2595}
### File: tutorials/advanced/image_captioning/include/data_utils.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <vector> #include "vocabulary.h" namespace data_utils { struct CaptionData { Vocabulary vocabulary; std::unordered_map<std::string, std::vector<std::s...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/data_utils.h", "license": "mit", "size": 1198}
### File: tutorials/advanced/image_captioning/include/decoder_rnn.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> /** * "Soft" attention network. * * Based on the paper "Show, Attend and Tell: Neural Image Caption Generation with Visual Attention" * (see https://arxiv.org/pdf...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/decoder_rnn.h", "license": "mit", "size": 2139}
### File: tutorials/advanced/image_captioning/include/encoder_cnn.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <utility> class EncoderCNNImpl : public torch::nn::Module { public: EncoderCNNImpl(const std::string &backbone_scriptmodule_file_path, int64_t out_wh, i...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/encoder_cnn.h", "license": "mit", "size": 748}
### File: tutorials/advanced/image_captioning/include/scheduler.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <vector> #include <algorithm> namespace scheduler { template<typename TOptimizer> struct OptimizerOptionsMap { }; template<> struct OptimizerOptionsMap<torch:...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/scheduler.h", "license": "mit", "size": 3038}
### File: tutorials/advanced/image_captioning/include/score.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <vector> #include <string> #include <iterator> namespace score { struct CountFraction { size_t numerator = 0; size_t denominator = 0; CountFraction &o...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/score.h", "license": "mit", "size": 1317}
### File: tutorials/advanced/image_captioning/include/transform.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <random> #include <vector> #include "caption_dataset.h" namespace transform { double rand_double(); int64_t rand_int(int64_t max); struct CaptionBatchTarget...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/transform.h", "license": "mit", "size": 2549}
### File: tutorials/advanced/image_captioning/include/validate.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <vector> #include <iostream> #include "vocabulary.h" #include "image_io.h" template<typename TDataset> using ValidationLoader = std::unique_ptr<torch::data::Sta...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/validate.h", "license": "mit", "size": 7865}
### File: tutorials/advanced/image_captioning/include/vocabulary.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <string> #include <unordered_map> #include <vector> namespace data_utils { class Vocabulary { public: Vocabulary(); int64_t add_word(const std::stri...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/include/vocabulary.h", "license": "mit", "size": 594}
### File: tutorials/advanced/image_captioning/model/create_encoder_cnn_backbone_scriptmodule.py import torch import torchvision import argparse class EncoderCNNBackbone(torch.nn.Module): def __init__(self): super(EncoderCNNBackbone, self).__init__() resnet_children = list(torchvision.model...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/model/create_encoder_cnn_backbone_scriptmodule.py", "license": "mit", "si...
### File: tutorials/advanced/image_captioning/src/caption_dataset.cpp // Copyright 2020-present pytorch-cpp Authors #include "caption_dataset.h" #include <torch/torch.h> #include <vector> #include <algorithm> #include <random> #include "vocabulary.h" #include "image_io.h" using torch::indexing::Slice; using torch::ind...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/caption_dataset.cpp", "license": "mit", "size": 3223}
### File: tutorials/advanced/image_captioning/src/data_utils.cpp // Copyright 2020-present pytorch-cpp Authors #include "data_utils.h" #include <string> #include <fstream> #include <vector> using torch::indexing::Slice; using torch::indexing::None; namespace data_utils { namespace { std::vector<std::string> tokenize_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/data_utils.cpp", "license": "mit", "size": 4373}
### File: tutorials/advanced/image_captioning/src/decoder_rnn.cpp // Copyright 2020-present pytorch-cpp Authors #include "decoder_rnn.h" #include <torch/types.h> using torch::indexing::Slice; using torch::indexing::Ellipsis; using torch::indexing::None; AttentionBlockImpl::AttentionBlockImpl(int64_t encoder_features,...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/decoder_rnn.cpp", "license": "mit", "size": 8605}
### File: tutorials/advanced/image_captioning/src/encoder_cnn.cpp // Copyright 2020-present pytorch-cpp Authors #include "encoder_cnn.h" #include <torch/script.h> EncoderCNNImpl::EncoderCNNImpl(const std::string &backbone_scriptmodule_file_path, int64_t out_wh, int64_t out_size) : pool(torch::nn::AdaptiveAvgPo...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/encoder_cnn.cpp", "license": "mit", "size": 2002}
### File: tutorials/advanced/image_captioning/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include <sstream> #include <vector> #include <chrono> #include "cxxopts.hpp" #include "vocabulary.h" #include "data_utils.h" #include "caption_datase...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/main.cpp", "license": "mit", "size": 15876}
### File: tutorials/advanced/image_captioning/src/score.cpp // Copyright 2020-present pytorch-cpp Authors #include "score.h" #include <vector> #include <cmath> namespace score { namespace { torch::Tensor n_grams(const torch::Tensor &sequence, size_t n) { return static_cast<size_t>(sequence.size(0)) < n ? ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/score.cpp", "license": "mit", "size": 4290}
### File: tutorials/advanced/image_captioning/src/transform.cpp // Copyright 2020-present pytorch-cpp Authors #include "transform.h" #include <cmath> #include <vector> using torch::indexing::Slice; using torch::indexing::Ellipsis; using torch::indexing::None; namespace transform { double rand_double() { return to...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/transform.cpp", "license": "mit", "size": 3190}
### File: tutorials/advanced/image_captioning/src/vocabulary.cpp // Copyright 2020-present pytorch-cpp Authors #include "vocabulary.h" #include <algorithm> #include <iostream> namespace data_utils { Vocabulary::Vocabulary() { add_word("<pad>"); add_word("<start>"); add_word("<end>"); add_word("<unk>");...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/image_captioning/src/vocabulary.cpp", "license": "mit", "size": 798}
### File: tutorials/advanced/neural_style_transfer/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(neural-style-transfer VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME neural-style-transfer) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/neural_style_transfer/CMakeLists.txt", "license": "mit", "size": 1422}
### File: tutorials/advanced/neural_style_transfer/include/vggnet.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <utility> #include <set> enum class Layer { CONV64, CONV128, CONV256, CONV512, MAXPOOL }; class VGGNetImpl : public torch::nn::Module { public: VGGNetI...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/neural_style_transfer/include/vggnet.h", "license": "mit", "size": 1118}
### File: tutorials/advanced/neural_style_transfer/model/create_vgg19_layers_scriptmodule.py import torch import torchvision def main(): # Download and load the pretrained VGG19 layers. vgg_19_layers = torchvision.models.vgg19(pretrained=True).features for param in vgg_19_layers.parameters(): par...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/neural_style_transfer/model/create_vgg19_layers_scriptmodule.py", "license": "mit", "size"...
### File: tutorials/advanced/neural_style_transfer/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include <fstream> #include "vggnet.h" #include "image_io.h" using image_io::load_image; using image_io::save_image; void print_sizes(torch::Ten...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/neural_style_transfer/src/main.cpp", "license": "mit", "size": 5563}
### File: tutorials/advanced/neural_style_transfer/src/vggnet.cpp // Copyright 2020-present pytorch-cpp Authors #include "vggnet.h" #include <utility> namespace { void initialize_weights(const torch::nn::Module& module) { torch::NoGradGuard no_grad; if (auto conv2d = module.as<torch::nn::Conv2d>()...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/neural_style_transfer/src/vggnet.cpp", "license": "mit", "size": 3633}
### File: tutorials/advanced/variational_autoencoder/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(variational-autoencoder VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME variational-autoencoder) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/variational_autoencoder/CMakeLists.txt", "license": "mit", "size": 1184}
### File: tutorials/advanced/variational_autoencoder/include/variational_autoencoder.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <utility> struct VAEOutput { torch::Tensor reconstruction; torch::Tensor mu; torch::Tensor log_var; }; class VAEImpl : public...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/variational_autoencoder/include/variational_autoencoder.h", "license": "mit", "size": 722}
### File: tutorials/advanced/variational_autoencoder/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "variational_autoencoder.h" #include "image_io.h" using image_io::save_image; int main() { std::cout << "Variational Autoencoder\...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/variational_autoencoder/src/main.cpp", "license": "mit", "size": 4267}
### File: tutorials/advanced/variational_autoencoder/src/variational_autoencoder.cpp // Copyright 2020-present pytorch-cpp Authors #include "variational_autoencoder.h" #include <utility> VAEImpl::VAEImpl(int64_t image_size, int64_t h_dim, int64_t z_dim) : fc1(image_size, h_dim), fc2(h_dim, z_dim), fc3(...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/advanced/variational_autoencoder/src/variational_autoencoder.cpp", "license": "mit", "size": 1540}
### File: tutorials/basics/feedforward_neural_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(feedforward-neural-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME feedforward-neural-network) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.c...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/feedforward_neural_network/CMakeLists.txt", "license": "mit", "size": 1010}
### File: tutorials/basics/feedforward_neural_network/include/neural_net.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class NeuralNetImpl : public torch::nn::Module { public: NeuralNetImpl(int64_t input_size, int64_t hidden_size, int64_t num_classes); torch::Tensor f...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/feedforward_neural_network/include/neural_net.h", "license": "mit", "size": 364}
### File: tutorials/basics/feedforward_neural_network/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "neural_net.h" int main() { std::cout << "FeedForward Neural Network\n\n"; // Device auto cuda_available = torch::cuda::...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/feedforward_neural_network/src/main.cpp", "license": "mit", "size": 4307}
### File: tutorials/basics/feedforward_neural_network/src/neural_net.cpp // Copyright 2020-present pytorch-cpp Authors #include "neural_net.h" #include <torch/torch.h> NeuralNetImpl::NeuralNetImpl(int64_t input_size, int64_t hidden_size, int64_t num_classes) : fc1(input_size, hidden_size), fc2(hidden_size, num_cla...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/feedforward_neural_network/src/neural_net.cpp", "license": "mit", "size": 464}
### File: tutorials/basics/linear_regression/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(linear-regression VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME linear-regression) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE main.cpp) target_link_libraries(${EX...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/linear_regression/CMakeLists.txt", "license": "mit", "size": 721}
### File: tutorials/basics/linear_regression/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> int main() { std::cout << "Linear Regression\n\n"; // Device auto cuda_available = torch::cuda::is_available(); torch::Device device(cuda_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/linear_regression/main.cpp", "license": "mit", "size": 1804}
### File: tutorials/basics/logistic_regression/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(logistic-regression VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME logistic-regression) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE main.cpp) target_link_librarie...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/logistic_regression/CMakeLists.txt", "license": "mit", "size": 803}
### File: tutorials/basics/logistic_regression/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> int main() { std::cout << "Logistic Regression\n\n"; // Device auto cuda_available = torch::cuda::is_available(); torch::Device device(c...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/logistic_regression/main.cpp", "license": "mit", "size": 4305}
### File: tutorials/basics/pytorch_basics/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(pytorch-basics VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME pytorch-basics) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE main.cpp) target_link_libraries(${EXECUTABLE_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/pytorch_basics/CMakeLists.txt", "license": "mit", "size": 1197}
### File: tutorials/basics/pytorch_basics/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <torch/script.h> #include <iostream> #include <iomanip> void print_tensor_size(const torch::Tensor&); void print_script_module(const torch::jit::script::Module& module, size_t spaces = 0);...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/pytorch_basics/main.cpp", "license": "mit", "size": 11262}
### File: tutorials/basics/pytorch_basics/model/create_resnet18_scriptmodule.py import torch import torchvision def main(): # Source: https://github.com/yunjey/pytorch-tutorial/blob/master/tutorials/01-basics/pytorch_basics/main.py # Download and load the pretrained ResNet-18. model = torchvision.models.r...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/basics/pytorch_basics/model/create_resnet18_scriptmodule.py", "license": "mit", "size": 1116}
### File: tutorials/intermediate/bidirectional_recurrent_neural_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(bidirectional-recurrent-neural-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME bidirectional-recurrent-neural-network) add_executable(${EXECUTABLE_NAME}) target_so...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/bidirectional_recurrent_neural_network/CMakeLists.txt", "license": "mit", "size": 1026}
### File: tutorials/intermediate/bidirectional_recurrent_neural_network/include/bi_rnn.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class BiRNNImpl : public torch::nn::Module { public: BiRNNImpl(int64_t input_size, int64_t hidden_size, int64_t num_layers, int64_t num_clas...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/bidirectional_recurrent_neural_network/include/bi_rnn.h", "license": "mit", "size": 369}
### File: tutorials/intermediate/bidirectional_recurrent_neural_network/src/bi_rnn.cpp // Copyright 2020-present pytorch-cpp Authors #include "bi_rnn.h" #include <torch/torch.h> using torch::indexing::Slice; BiRNNImpl::BiRNNImpl(int64_t input_size, int64_t hidden_size, int64_t num_layers, int64_t num_classes) : l...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/bidirectional_recurrent_neural_network/src/bi_rnn.cpp", "license": "mit", "size": 1430}
### File: tutorials/intermediate/bidirectional_recurrent_neural_network/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "bi_rnn.h" int main() { std::cout << "Bidirectional Recurrent Neural Network\n\n"; // Device auto cuda...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/bidirectional_recurrent_neural_network/src/main.cpp", "license": "mit", "size": 4508}
### File: tutorials/intermediate/convolutional_neural_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(convolutional-neural-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME convolutional-neural-network) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVAT...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/CMakeLists.txt", "license": "mit", "size": 1164}
### File: tutorials/intermediate/convolutional_neural_network/include/convnet.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class ConvNetImpl : public torch::nn::Module { public: explicit ConvNetImpl(int64_t num_classes = 10); torch::Tensor forward(torch::Tensor x); ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/include/convnet.h", "license": "mit", "size": 1067}
### File: tutorials/intermediate/convolutional_neural_network/include/imagefolder_dataset.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/data/datasets/base.h> #include <torch/data/example.h> #include <torch/types.h> #include <string> #include <vector> #include <unordered_map> namespace d...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/include/imagefolder_dataset.h", "license": "mit", "size": 98...
### File: tutorials/intermediate/convolutional_neural_network/src/convnet.cpp // Copyright 2020-present pytorch-cpp Authors #include "convnet.h" #include <torch/torch.h> ConvNetImpl::ConvNetImpl(int64_t num_classes) : fc(64 * 4 * 4, num_classes) { register_module("layer1", layer1); register_module("layer2"...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/src/convnet.cpp", "license": "mit", "size": 589}
### File: tutorials/intermediate/convolutional_neural_network/src/imagefolder_dataset.cpp // Copyright 2020-present pytorch-cpp Authors #include <imagefolder_dataset.h> #include <torch/torch.h> #include <vector> #include <algorithm> #include <filesystem> #include <unordered_map> #include "image_io.h" namespace fs = st...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/src/imagefolder_dataset.cpp", "license": "mit", "size": 2271...
### File: tutorials/intermediate/convolutional_neural_network/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "convnet.h" #include "imagefolder_dataset.h" using dataset::ImageFolderDataset; int main() { std::cout << "Convolutional...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/convolutional_neural_network/src/main.cpp", "license": "mit", "size": 4496}
### File: tutorials/intermediate/deep_residual_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(deep-residual-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME deep-residual-network) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/CMakeLists.txt", "license": "mit", "size": 1309}
### File: tutorials/intermediate/deep_residual_network/include/cifar10.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/data/datasets/base.h> #include <torch/data/example.h> #include <torch/types.h> #include <cstddef> #include <fstream> #include <string> // CIFAR10 dataset // based on: htt...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/include/cifar10.h", "license": "mit", "size": 1393}
### File: tutorials/intermediate/deep_residual_network/include/residual_block.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> namespace resnet { class ResidualBlockImpl : public torch::nn::Module { public: ResidualBlockImpl(int64_t in_channels, int64_t out_channels, int64_t ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/include/residual_block.h", "license": "mit", "size": 694}
### File: tutorials/intermediate/deep_residual_network/include/resnet.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <vector> #include "residual_block.h" namespace resnet { template<typename Block> class ResNetImpl : public torch::nn::Module { public: explicit ResN...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/include/resnet.h", "license": "mit", "size": 2759}
### File: tutorials/intermediate/deep_residual_network/include/transform.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <random> #include <vector> namespace transform { class RandomHorizontalFlip : public torch::data::transforms::TensorTransform<torch::Tensor> { public...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/include/transform.h", "license": "mit", "size": 1888}
### File: tutorials/intermediate/deep_residual_network/src/cifar10.cpp // Copyright 2020-present pytorch-cpp Authors #include "cifar10.h" namespace { // CIFAR10 dataset description can be found at https://www.cs.toronto.edu/~kriz/cifar.html. constexpr uint32_t kTrainSize = 50000; constexpr uint32_t kTestSize = 10000; ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/src/cifar10.cpp", "license": "mit", "size": 3396}
### File: tutorials/intermediate/deep_residual_network/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "resnet.h" #include "cifar10.h" #include "transform.h" using resnet::ResNet; using resnet::ResidualBlock; using transform::ConstantP...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/src/main.cpp", "license": "mit", "size": 4936}
### File: tutorials/intermediate/deep_residual_network/src/residual_block.cpp // Copyright 2020-present pytorch-cpp Authors #include "residual_block.h" #include <torch/torch.h> namespace resnet { ResidualBlockImpl::ResidualBlockImpl(int64_t in_channels, int64_t out_channels, int64_t stride, torch::nn::Sequential d...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/src/residual_block.cpp", "license": "mit", "size": 1306}
### File: tutorials/intermediate/deep_residual_network/src/transform.cpp // Copyright 2020-present pytorch-cpp Authors #include "transform.h" #include <torch/torch.h> using torch::indexing::Slice; using torch::indexing::Ellipsis; namespace transform { namespace { double rand_double() { return torch::rand(...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/deep_residual_network/src/transform.cpp", "license": "mit", "size": 1561}
### File: tutorials/intermediate/language_model/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(language-model VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME language-model) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/CMakeLists.txt", "license": "mit", "size": 1371}
### File: tutorials/intermediate/language_model/include/corpus.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <string> #include "dictionary.h" namespace data_utils { class Corpus { public: explicit Corpus(const std::string& path) : path_(path) {} torch::Tensor ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/include/corpus.h", "license": "mit", "size": 446}
### File: tutorials/intermediate/language_model/include/dictionary.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <string> #include <unordered_map> #include <vector> namespace data_utils { class Dictionary { public: int64_t add_word(const std::string& word); std::string word_at_index(i...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/include/dictionary.h", "license": "mit", "size": 488}
### File: tutorials/intermediate/language_model/include/rnn_lm.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <tuple> class RNNLMImpl : public torch::nn::Module { public: RNNLMImpl(int64_t vocab_size, int64_t embed_size, int64_t hidden_size, int64_t num_layers); ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/include/rnn_lm.h", "license": "mit", "size": 528}
### File: tutorials/intermediate/language_model/src/corpus.cpp // Copyright 2020-present pytorch-cpp Authors #include "corpus.h" #include <torch/torch.h> #include <fstream> #include <sstream> #include <exception> #include <algorithm> namespace data_utils { torch::Tensor Corpus::get_data(int64_t batch_size) { ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/src/corpus.cpp", "license": "mit", "size": 1058}
### File: tutorials/intermediate/language_model/src/dictionary.cpp // Copyright 2020-present pytorch-cpp Authors #include "dictionary.h" namespace data_utils { int64_t Dictionary::add_word(const std::string& word) { auto it = word2idx_.find(word); if (it == word2idx_.end()) { idx2word_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/src/dictionary.cpp", "license": "mit", "size": 465}
### File: tutorials/intermediate/language_model/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include <fstream> #include <tuple> #include "rnn_lm.h" #include "corpus.h" using data_utils::Corpus; using torch::indexing::Slice; int main() { ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/src/main.cpp", "license": "mit", "size": 5030}
### File: tutorials/intermediate/language_model/src/rnn_lm.cpp // Copyright 2020-present pytorch-cpp Authors #include "rnn_lm.h" #include <torch/torch.h> #include <tuple> RNNLMImpl::RNNLMImpl(int64_t vocab_size, int64_t embed_size, int64_t hidden_size, int64_t num_layers) : embed(vocab_size, embed_size), lstm(...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/language_model/src/rnn_lm.cpp", "license": "mit", "size": 997}
### File: tutorials/intermediate/recurrent_neural_network/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(recurrent-neural-network VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME recurrent-neural-network) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.c...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/recurrent_neural_network/CMakeLists.txt", "license": "mit", "size": 992}
### File: tutorials/intermediate/recurrent_neural_network/include/rnn.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class RNNImpl : public torch::nn::Module { public: RNNImpl(int64_t input_size, int64_t hidden_size, int64_t num_layers, int64_t num_classes); torch::Tens...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/recurrent_neural_network/include/rnn.h", "license": "mit", "size": 363}
### File: tutorials/intermediate/recurrent_neural_network/src/main.cpp // Copyright 2020-present pytorch-cpp Authors #include <torch/torch.h> #include <iostream> #include <iomanip> #include "rnn.h" int main() { std::cout << "Recurrent Neural Network\n\n"; // Device auto cuda_available = torch::cuda::is_av...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/recurrent_neural_network/src/main.cpp", "license": "mit", "size": 4488}
### File: tutorials/intermediate/recurrent_neural_network/src/rnn.cpp // Copyright 2020-present pytorch-cpp Authors #include "rnn.h" #include <torch/torch.h> using torch::indexing::Slice; RNNImpl::RNNImpl(int64_t input_size, int64_t hidden_size, int64_t num_layers, int64_t num_classes) : lstm(torch::nn::LSTMOptio...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/intermediate/recurrent_neural_network/src/rnn.cpp", "license": "mit", "size": 575}
### File: tutorials/popular/blitz/autograd/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(autograd VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME autograd) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${TOR...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/autograd/CMakeLists.txt", "license": "mit", "size": 703}
### File: tutorials/popular/blitz/autograd/main.cpp // Copyright 2020-present pytorch-cpp Authors // Original: https://pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html #include <torch/torch.h> #include <iostream> #include <iomanip> int main() { std::cout << "Deep Learning with PyTorch: A 60 Minute Blitz...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/autograd/main.cpp", "license": "mit", "size": 2544}
### File: tutorials/popular/blitz/neural_networks/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(neural-networks VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME neural-networks) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/neural_networks/CMakeLists.txt", "license": "mit", "size": 898}
### File: tutorials/popular/blitz/neural_networks/include/nnet.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class NetImpl : public torch::nn::Module { public: NetImpl(); torch::Tensor forward(torch::Tensor x); torch::nn::Conv2d conv1; torch::nn::Conv2d conv2;...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/neural_networks/include/nnet.h", "license": "mit", "size": 415}
### File: tutorials/popular/blitz/neural_networks/src/main.cpp // Copyright 2020-present pytorch-cpp Authors // Original: https://pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html #include <torch/torch.h> #include <iostream> #include <iomanip> #include "nnet.h" int main() { std::cout << "Deep Lear...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/neural_networks/src/main.cpp", "license": "mit", "size": 2319}
### File: tutorials/popular/blitz/neural_networks/src/nnet.cpp // Copyright 2020-present pytorch-cpp Authors #include "nnet.h" #include <torch/torch.h> NetImpl::NetImpl() : conv1(torch::nn::Conv2dOptions(1, 6, 3)), conv2(torch::nn::Conv2dOptions(6, 16, 3)), fc1(torch::nn::LinearOptions(16 * 6 * 6, 120)), ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/neural_networks/src/nnet.cpp", "license": "mit", "size": 1307}
### File: tutorials/popular/blitz/tensors/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(tensors VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME tensors) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE main.cpp) target_link_libraries(${EXECUTABLE_NAME} ${TORCH_...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/tensors/CMakeLists.txt", "license": "mit", "size": 701}
### File: tutorials/popular/blitz/tensors/main.cpp // Copyright 2020-present pytorch-cpp Authors // Original: https://pytorch.org/tutorials/beginner/blitz/tensor_tutorial.html #include <torch/torch.h> #include <iostream> #include <iomanip> int main() { std::cout << "Deep Learning with PyTorch: A 60 Minute Blitz\n\...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/tensors/main.cpp", "license": "mit", "size": 2382}
### File: tutorials/popular/blitz/training_a_classifier/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(training-a-classifier VERSION 1.0.0 LANGUAGES CXX) set(EXECUTABLE_NAME training-a-classifier) add_executable(${EXECUTABLE_NAME}) target_sources(${EXECUTABLE_NAME} PRIVATE src/main.cpp ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/CMakeLists.txt", "license": "mit", "size": 1108}
### File: tutorials/popular/blitz/training_a_classifier/include/cifar10.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/data/datasets/base.h> #include <torch/data/example.h> #include <torch/types.h> #include <cstddef> #include <fstream> #include <string> // CIFAR10 dataset // based on: ht...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/include/cifar10.h", "license": "mit", "size": 1393}
### File: tutorials/popular/blitz/training_a_classifier/include/nnet.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> class NetImpl : public torch::nn::Module { public: NetImpl(); torch::Tensor forward(torch::Tensor x); private: torch::nn::Conv2d conv1; torch::n...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/include/nnet.h", "license": "mit", "size": 401}
### File: tutorials/popular/blitz/training_a_classifier/src/cifar10.cpp // Copyright 2020-present pytorch-cpp Authors #include "cifar10.h" namespace { // CIFAR10 dataset description can be found at https://www.cs.toronto.edu/~kriz/cifar.html. constexpr uint32_t kTrainSize = 50000; constexpr uint32_t kTestSize = 10000;...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/src/cifar10.cpp", "license": "mit", "size": 3396}
### File: tutorials/popular/blitz/training_a_classifier/src/main.cpp // Copyright 2020-present pytorch-cpp Authors // Original: https://pytorch.org/tutorials/beginner/blitz/cifar10_tutorial.html #include <torch/torch.h> #include <iostream> #include <vector> #include <iomanip> #include "nnet.h" #include "cifar10.h" int...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/src/main.cpp", "license": "mit", "size": 4101}
### File: tutorials/popular/blitz/training_a_classifier/src/nnet.cpp // Copyright 2020-present pytorch-cpp Authors #include "nnet.h" #include <torch/torch.h> NetImpl::NetImpl() : conv1(torch::nn::Conv2dOptions(3, 6, 5)), pool(torch::nn::MaxPool2dOptions({2, 2})), conv2(torch::nn::Conv2dOptions(6, 16, 5)), ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "tutorials/popular/blitz/training_a_classifier/src/nnet.cpp", "license": "mit", "size": 892}
### File: utils/image_io/CMakeLists.txt cmake_minimum_required(VERSION 3.14 FATAL_ERROR) project(image-io VERSION 1.0.0 LANGUAGES CXX) if(NOT Torch_FOUND) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake") find_package(Torch REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/../../libtorch") en...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/pytorch-cpp", "path": "utils/image_io/CMakeLists.txt", "license": "mit", "size": 680}
### File: utils/image_io/include/image_io.h // Copyright 2020-present pytorch-cpp Authors #pragma once #include <torch/torch.h> #include <string> namespace image_io { enum class ImageFormat { PNG, JPG, BMP }; torch::Tensor load_image(const std::string& file_path, torch::IntArrayRef shape = {}, ...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "utils/image_io/include/image_io.h", "license": "mit", "size": 722}
### File: utils/image_io/src/image_io.cpp // Copyright 2020-present pytorch-cpp Authors #include "image_io.h" #include <torch/torch.h> #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image_write.h" #define STB_IMAGE_RESIZE_IMPLEMENTATION #include "stb_imag...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "C++", "repo_name": "minhanghuang/pytorch-cpp", "path": "utils/image_io/src/image_io.cpp", "license": "mit", "size": 6096}
### File: qt_dotgraph/CMakeLists.txt cmake_minimum_required(VERSION 3.5) project(qt_dotgraph) find_package(ament_cmake REQUIRED) find_package(ament_cmake_python REQUIRED) ament_python_install_package(${PROJECT_NAME} PACKAGE_DIR src/${PROJECT_NAME}) if(BUILD_TESTING) find_package(ament_cmake_pytest REQUIRED) fi...
{"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "CMake", "repo_name": "minhanghuang/qt_gui_core", "path": "qt_dotgraph/CMakeLists.txt", "license": "bsd-3-clause", "size": 658}