TorchScan 项目使用教程

TorchScan 项目使用教程

torch-scanSeamless analysis of your PyTorch models (RAM usage, FLOPs, MACs, receptive field, etc.)项目地址:https://gitcode.com/gh_mirrors/to/torch-scan

1. 项目的目录结构及介绍

TorchScan 项目的目录结构如下:

torch-scan/
├── docs/
│   ├── _build/
│   ├── _static/
│   ├── _templates/
│   ├── conf.py
│   ├── index.rst
│   ├── installation.rst
│   ├── modules.rst
│   ├── notes.rst
│   ├── README.md
│   └── changelog.rst
├── torchscan/
│   ├── __init__.py
│   ├── modules/
│   │   ├── __init__.py
│   │   ├── conv.py
│   │   ├── linear.py
│   │   ├── normalization.py
│   │   ├── other.py
│   │   ├── pooling.py
│   │   └── non_linear_activations.py
│   ├── process.py
│   ├── utils.py
│   └── summary.py
├── tests/
│   ├── __init__.py
│   ├── test_modules.py
│   ├── test_process.py
│   └── test_utils.py
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── requirements.txt
└── setup.py

目录介绍

  • docs/:包含项目的文档文件,使用 Sphinx 生成。
  • torchscan/:包含项目的主要代码文件。
    • modules/:包含各种模块的实现代码。
    • process.py:处理模块的文件。
    • utils.py:工具函数文件。
    • summary.py:生成模型摘要的文件。
  • tests/:包含项目的测试文件。
  • .gitignore:Git 忽略文件。
  • CONTRIBUTING.md:贡献指南。
  • LICENSE:项目许可证。
  • README.md:项目介绍文件。
  • requirements.txt:项目依赖文件。
  • setup.py:项目安装文件。

2. 项目的启动文件介绍

项目的启动文件是 setup.py,它用于安装和管理项目的依赖。可以通过以下命令安装项目:

pip install .

3. 项目的配置文件介绍

项目的配置文件主要有两个:

  1. setup.py:用于配置项目的安装信息和依赖。
  2. docs/conf.py:用于配置项目的文档生成信息,使用 Sphinx 生成文档时会用到。

setup.py 配置文件

setup.py 文件的主要内容如下:

from setuptools import setup, find_packages

setup(
    name='torchscan',
    version='0.1.0',
    description='Torchscan: meaningful module insights',
    author='François-Guillaume Fernandez',
    author_email='your-email@example.com',
    url='https://github.com/frgfm/torch-scan',
    packages=find_packages(),
    install_requires=[
        'torch',
        'torchvision',
        # 其他依赖
    ],
    classifiers=[
        'Development Status :: 3 - Alpha',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: Apache Software License',
        'Programming Language :: Python :: 3',
        'Programming Language :: Python :: 3.6',
        'Programming Language :: Python :: 3.7',
        'Programming Language :: Python :: 3.8',
    ],
)

docs/conf.py 配置文件

docs/conf.py 文件的主要内容如下:

import os
import sys
sys.path.insert(0, os.path.abspath('..'))

project = 'TorchScan'
copyright = '2020-2022, François-Guillaume Fernandez'
author = 'François-Guillaume Fernandez'

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.napoleon',
]

templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

html_theme = 'furo'
html_static_path = ['_static']

以上是 TorchScan 项目的目录

torch-scanSeamless analysis of your PyTorch models (RAM usage, FLOPs, MACs, receptive field, etc.)项目地址:https://gitcode.com/gh_mirrors/to/torch-scan

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荣宣廷

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值