Skip to content

Commit

Permalink
add dataset readme
Browse files Browse the repository at this point in the history
  • Loading branch information
clearhanhui committed Jun 9, 2023
1 parent c426f9d commit ba1cf82
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions chap4_2/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 数据集和数据加载

关于自定义 DataSet 可以参考 AllentDan 的博客,[中文版](https://zhuanlan.zhihu.com/p/369930525)[英文版](https://github.com/AllentDan/LibtorchTutorials/tree/main/lesson4-DatasetUtilization)
DataLoader 一般不需要改动,用法在[第五章](../chap5)中可以找到,主要是 `make_data_loader` 函数。
2 changes: 1 addition & 1 deletion chap7/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ PYBIND11_MODULE(gc_cpp, m) {
m.def("backward", &gc_backward, "gc backward");
}
```
`PYBIND11_MODULE` 的第一个参数 `gc_cpp` 是我们后面需要 `import` 的包名,`m` 是一个 `library` 对象,`def` 的三个参数分别是暴露给 python 的函数名,函数的指针,和描述。关于宏 `PYBIND11_MODULE` 的详细文档可以看[这里](https://pybind11.readthedocs.io/en/stable/reference.html#c.PYBIND11_MODULE)
`PYBIND11_MODULE` 的第一个参数 `gc_cpp` 是我们后面需要 `import` 的包名,`m` 是一个 `library` 对象,`def` 的三个参数分别是暴露给 python 的函数名,函数的指针,和描述。关于宏 `PYBIND11_MODULE` 的详细文档可以看[官网描述](https://pybind11.readthedocs.io/en/stable/reference.html#c.PYBIND11_MODULE)
> 提一句,这个宏其实帮我们做了很多事情,如果不使用 PyBind11 的话,可以参考这两个文档:[链接1](https://docs.python.org/3/extending/extending.html)[链接2](https://docs.microsoft.com/zh-cn/visualstudio/python/working-with-c-cpp-python-in-visual-studio?view=vs-2022#use-cpython-extensions)。当然这个除了封装函数,像类、属性、等都可以封装,这其实利用了就是 python 一切皆对象的特性。
然后在同一个目录下创建 `setup.py` ,最简单的只需要这几行代码(对我提供的代码做了简化):
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ LibTorch 是什么呢,简单来讲可以认为它提供了一种 c++ 前端(
* [2--张量基础](./chap2/)
* [3--自动微分(1)](./chap3/)
* [4--基本模型](./chap4/)
* [4_2--数据集和数据加载](./chap4_2/)
* [5--模型实践](./chap5/)
* [6--TorchScript](./chap6/)
* [7--PyTorch拓展](./chap7/)
Expand All @@ -31,7 +32,7 @@ LibTorch 是什么呢,简单来讲可以认为它提供了一种 c++ 前端(

## 软件环境

必要的软件和详细的环境配置可以参考[这里](./chap0/)
必要的软件和详细的环境配置可以参考[chap0](./chap0/)


----------------
Expand Down

0 comments on commit ba1cf82

Please sign in to comment.