建议使用以下浏览器,以获得最佳体验。 IE 9.0+以上版本 Chrome 31+ 谷歌浏览器 Firefox 30+ 火狐浏览器
设置昵称

在此一键设置昵称,即可参与社区互动!

确定
我再想想
选择版块
MindSpore 主题:3176帖子:10177

已解决

【 问题求助-执行问题】

当使用pynative模式时能跑出loss,可是换成graph模式报错

liqupr 2021/6/8 304

报错原因

Traceback (most recent call last):
  File "/home/hulijuan/code/ECO-mindspore/eco4-1/train.py", line 160, in <module>
    run_train()
  File "/home/hulijuan/code/ECO-mindspore/eco4-1/train.py", line 156, in run_train
    final_net.train(epoch=args.epochs, train_dataset=train_dataset, callbacks=[ckpoint, LossMonitor(10)], dataset_sink_mode=False)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 627, in train
    sink_size=sink_size)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 407, in _train
    self._train_process(epoch, train_dataset, list_callback, cb_params)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 536, in _train_process
    outputs = self._train_network(*next_element)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 341, in __call__
    out = self.compile_and_run(*inputs)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 608, in compile_and_run
    self.compile(*inputs)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 595, in compile
    _executor.compile(self, *inputs, phase=self.phase, auto_parallel_mode=self._auto_parallel_mode)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/common/api.py", line 494, in compile
    result = self._executor.compile(obj, args_list, phase, use_vm)
RuntimeError: Unable to cast from non-held to held instance (T& to Holder<T>) of type 'std::shared_ptr<mindspore::Cell>''

Process finished with exit code 1

construct代码:

    def construct(self, input):

        sample_len = (3 if self.modality == "RGB" else 2) * self.new_length

        if self.modality == 'RGBDiff':
            sample_len = 3 * self.new_length
            input = self._get_diff(input)

        if self.base_model_name == "C3DRes18":
            before_permute = input.view((-1, sample_len) + input.size()[-2:])
            input_var = ms.ops.Transpose(before_permute.view((-1, self.num_segments) + before_permute.size()[1:]), 1, 2)
        else:
            input_var = input.view((-1, sample_len) + input.shape[-2:])
        base_out = self.base_model(input_var)

        if self.dropout > 0:
            base_out = self.new_fc(base_out)

        if not self.before_softmax:
            base_out = self.softmax(base_out)
        if self.reshape:
            base_out = self.consensus.construct(base_out)
            return base_out
        return base_out

回复2

2021/6/9 09:23

用户您好,上面问题已经收到,会尽快给您答复,请耐心等待一下哦~

chengxiaoli

2021-6-15 09:06

用户您好,感谢您使用MindSpore。 因为较长时间未收到您的回应,所以这里对您的问题进行了结帖。 如果您有其他问题可以创建新的问题帖继续提问,谢谢您的支持~
... 展开
YC-毓
0 0
2021/6/9 14:13

你好,建议可以先将‘self.consensus.construct()’修改成‘self.consensus()’调用试试。

也可以将完整的代码展示出来分析一下。

上划加载中
直达楼层
标签
您还可以添加5个标签
  • 没有搜索到和“关键字”相关的标签
  • 云产品
  • 解决方案
  • 技术领域
  • 通用技术
  • 平台功能
取消

采纳成功

您已采纳当前回复为最佳回复

liqupr

发帖: 30粉丝: 0

发消息 + 关注

发表于2021年06月08日 21:09:16 304 2
直达本楼层的链接
楼主
显示全部楼层
[执行问题] 当使用pynative模式时能跑出loss,可是换成graph模式报错

报错原因

Traceback (most recent call last):
  File "/home/hulijuan/code/ECO-mindspore/eco4-1/train.py", line 160, in <module>
    run_train()
  File "/home/hulijuan/code/ECO-mindspore/eco4-1/train.py", line 156, in run_train
    final_net.train(epoch=args.epochs, train_dataset=train_dataset, callbacks=[ckpoint, LossMonitor(10)], dataset_sink_mode=False)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 627, in train
    sink_size=sink_size)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 407, in _train
    self._train_process(epoch, train_dataset, list_callback, cb_params)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/train/model.py", line 536, in _train_process
    outputs = self._train_network(*next_element)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 341, in __call__
    out = self.compile_and_run(*inputs)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 608, in compile_and_run
    self.compile(*inputs)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/nn/cell.py", line 595, in compile
    _executor.compile(self, *inputs, phase=self.phase, auto_parallel_mode=self._auto_parallel_mode)
  File "/usr/local/python-3.7.5/lib/python3.7/site-packages/mindspore/common/api.py", line 494, in compile
    result = self._executor.compile(obj, args_list, phase, use_vm)
RuntimeError: Unable to cast from non-held to held instance (T& to Holder<T>) of type 'std::shared_ptr<mindspore::Cell>''

Process finished with exit code 1

construct代码:

    def construct(self, input):

        sample_len = (3 if self.modality == "RGB" else 2) * self.new_length

        if self.modality == 'RGBDiff':
            sample_len = 3 * self.new_length
            input = self._get_diff(input)

        if self.base_model_name == "C3DRes18":
            before_permute = input.view((-1, sample_len) + input.size()[-2:])
            input_var = ms.ops.Transpose(before_permute.view((-1, self.num_segments) + before_permute.size()[1:]), 1, 2)
        else:
            input_var = input.view((-1, sample_len) + input.shape[-2:])
        base_out = self.base_model(input_var)

        if self.dropout > 0:
            base_out = self.new_fc(base_out)

        if not self.before_softmax:
            base_out = self.softmax(base_out)
        if self.reshape:
            base_out = self.consensus.construct(base_out)
            return base_out
        return base_out
举报
分享

分享文章到朋友圈

分享文章到微博

采纳成功

您已采纳当前回复为最佳回复

chengxiaoli

发帖: 303粉丝: 41

级别 : 版主,版块专家

发消息 + 关注

发表于2021年06月09日 09:23:37
直达本楼层的链接
沙发
显示全部楼层

用户您好,上面问题已经收到,会尽快给您答复,请耐心等待一下哦~

评论
chengxiaoli 2021-6-15 09:06 评论

用户您好,感谢您使用MindSpore。 因为较长时间未收到您的回应,所以这里对您的问题进行了结帖。 如果您有其他问题可以创建新的问题帖继续提问,谢谢您的支持~

... 查看全部
点赞 评论 引用 举报

采纳成功

您已采纳当前回复为最佳回复

YC-毓

发帖: 3粉丝: 1

发消息 + 关注

发表于2021年06月09日 14:13:33
直达本楼层的链接
板凳
显示全部楼层

你好,建议可以先将‘self.consensus.construct()’修改成‘self.consensus()’调用试试。

也可以将完整的代码展示出来分析一下。

点赞 评论 引用 举报

游客

富文本
Markdown
您需要登录后才可以回帖 登录 | 立即注册

邀请回答
您可以邀请3位专家

结贴

您对问题的回复是否满意?
满意度
非常满意 满意 一般 不满意
我要反馈
0/200