mobilenet_v3_tvm图像分类模型

MobileNet_v3

论文

Searching for MobileNetV3

https://arxiv.org/pdf/1905.02244.pdf

模型结构

MobileNetv3模型采用轻量级的深度可分离卷积(depthwise separable convolution)结构,以减少模型参数量和计算复杂度。

算法原理

MobileNetv3模型采用混合使用轻量级深度可分离卷积和逆残差结构(Inverted Residuals)的算法原理,以实现高效计算和良好的模型性能

环境配置

Docker(方法一)

此处提供光源拉取docker镜像的地址与使用步骤

docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:tvm_fp32_dtk22.10.1_py38_centos-7.6-latest
docker run -it -v /path/your_code_data/:/path/your_code_data/ --shm-size=32G --privileged=true --device=/dev/kfd --device=/dev/dri/ --group-add video --name docker_name imageID bash
cd /root/tvm-0.11-dev0/apps/
git clone  http://developer.hpccube.com/codes/modelzoo/mobilenet_v3_tvm.git

数据集

在本测试中可以使用ImageNet数据集。 下载ImageNet数据集:ImageNet 数据结构如下:

data
    ├──imagenet
        ├── meta
            ├──val.txt
            ├──train.txt
            ...
        ├── train
        ├── val

推理

Python Deploy测试参考:

    cd  mobilenet_v3_tvm
    ulimit -s unlimited
    export MIOPEN_DEBUG_CONV_IMPLICIT_GEMM=0
    export HIP_VISIBLE_DEVICES=2(此处修改为对应加速卡ID号)
    python  val_onnx.py --test-only  --data-path /parastor/DL_DATA/ImageNet-pytorch --model mobilenet_v3_large --b 1 --pretrained

result

精度

测试数据:ImageNet-pytorch,使用的加速卡:Z100L。

Acc@1Acc@5
74.05491.340

应用场景

算法类别

图像分类

热点行业

制造,能源,交通,网安

源码仓库及问题反馈

ModelZoo / Mobilenet_v3_tvm · GitLab

参考资料

https://github.com/open-mmlab/mmpretrain

TVM的te(Tensor Expression)中,`tvm.te.if_then_else` 函数用于实现条件语句,根据一个布尔条件选择执行不同的计算逻辑。 `if_then_else` 函数的基本语法如下: ```python tvm.te.if_then_else(condition, then_expr, else_expr) ``` 参数说明: - `condition`:布尔条件表达式,用于决定选择哪个分支的计算逻辑。 - `then_expr`:当条件为真时执行的计算表达式。 - `else_expr`:当条件为假时执行的计算表达式。 下面是一个示例代码,演示如何使用 `if_then_else` 函数: ```python import tvm from tvm import te def if_then_else_example(): # 输入张量形状 shape = (4, ) # 创建输入和输出张量 input_tensor = te.placeholder(shape, name='input_tensor', dtype='float32') output_tensor = te.placeholder(shape, name='output_tensor', dtype='float32') # 定义计算 def compute(i): # 根据输入张量的值判断条件 condition = input_tensor[i] > 0 # 根据条件选择执行计算逻辑 then_expr = input_tensor[i] * 2 else_expr = input_tensor[i] / 2 # 使用 if_then_else 函数实现条件选择 return tvm.te.if_then_else(condition, then_expr, else_expr) # 创建计算描述 output = te.compute(shape, compute, name='output') return output.op.body[0] # 创建一个范围上下文 with tvm.target.Target('llvm'): # 构造计算图 stmt = if_then_else_example() # 打印生成的计算图 print(stmt) ``` 在上述示例中,我们定义了一个 `if_then_else_example()` 函数,创建了输入张量和输出张量。然后在 `compute()` 中,根据输入张量的值判断条件,并使用 `if_then_else` 函数实现条件选择:当输入张量大于0时,执行乘以2的计算逻辑;否则,执行除以2的计算逻辑。最后通过 `te.compute()` 创建计算描述,并返回计算图的第一个操作节点。 希望这能解答您的疑问!如果您还有其他问题,请随时提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

技术瘾君子1573

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

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

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

打赏作者

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

抵扣说明:

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

余额充值