从MindSpore Hub加载模型总结

转载地址:https://bbs.huaweicloud.com/forum/thread-112009-1-1.html

作者:李响

邮箱:lixiang97@huawei.com

想使用GoogleNet对CIFAR-10数据集进行分类,可以在MindSpore Hub官网上使用关键词GoogleNet进行搜索。页面将会返回与GoogleNet相关的所有模型。进入相关模型页面之后,获得详情页url,相关链接:https://www.mindspore.cn/resources/hub

示例代码如下

import mindspore_hub as mshub

import mindspore

from mindspore import context, Tensor, nn, Model

from mindspore import dtype as mstype

import mindspore.dataset.vision.py_transforms as py_transforms

context.set_context(mode=context.GRAPH_MODE,

                     device_target="Ascend",      #根据自身环境设置,若使用CPU或者GPU可替换

                     device_id=0)

model = "mindspore/ascend/0.7/googlenet_v1_cifar10"

# Initialize the number of classes based on the pre-trained model.

network = mshub.load(model, num_classes=10)

network.set_train(False)

# ...

完成模型加载后,可以使用MindSpore进行推理,参考https://www.mindspore.cn/tutorial/inference/zh-CN/r1.1/multi_platform_inference.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值