terminate called after throwing an instance of ‘c10::IndexError‘


terminate called after throwing an instance of 'c10::IndexError'
  what():  select(): index 3 out of range for tensor of size [3] at dimension 0 (select at ../aten/src/ATen/native/TensorShape.cpp:765)
  frame #0: c10::Error::Error(c10::SourceLocation, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) + 0x6a (0x7fc09b944aaa in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libc10.so)
frame #1: at::native::select(at::Tensor const&, long, long) + 0x3fc (0x7fc08bdaafcc in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch_cpu.so)
frame #2: <unknown function> + 0x12269dd (0x7fc08c0d79dd in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch_cpu.so)
frame #3: <unknown function> + 0x120ddb7 (0x7fc08c0bedb7 in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch_cpu.so)
frame #4: <unknown function> + 0x2beb918 (0x7fc08da9c918 in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch_cpu.so)
frame #5: <unknown function> + 0x120ddb7 (0x7fc08c0bedb7 in /opt/libtorch-cxx11-abi-shared-with-deps-1.5.0/libtorch/lib/libtorch_cpu.so)
frame #6: at::Tensor c10::KernelFunction::callUnboxed<at::Tensor, at::Tensor const&, long, long>(c10::OperatorHandle const&, at::Tensor const&, long, long) const + 0xd5 (0x55e69fa3676d in ./example-app)
frame #7: at::Tensor c10::Dispatcher::callUnboxedWithDispatchKey<at::Tensor, at::Tensor const&, long, long>(c10::OperatorHandle const&, c10::DispatchKey, at::Tensor const&, long, long) const + 0xc1 (0x55e69fa2f23b in ./example-app)
frame #8: at::Tensor c10::Dispatcher::callUnboxed<at::Tensor, at::Tensor const&, long, long>(c10::OperatorHandle const&, at::Tensor const&, long, long) const + 0xbb (0x55e69fa2660f in ./example-app)
frame #9: at::Tensor c10::OperatorHandle::callUnboxed<at::Tensor, at::Tensor const&, long, long>(at::Tensor const&, long, long) const + 0x7e (0x55e69fa1b7ca in ./example-app)
frame #10: at::Tensor::select(long, long) const + 0xa5 (0x55e69fa0d525 in ./example-app)
frame #11: at::Tensor::operator[](long) const + 0x3f (0x55e69fa0ee9f in ./example-app)
frame #12: main + 0x66c (0x55e69fa01274 in ./example-app)
frame #13: __libc_start_main + 0xe7 (0x7fc048536b97 in /lib/x86_64-linux-gnu/libc.so.6)
frame #14: _start + 0x2a (0x55e69f9fec1a in ./example-app)

已放弃 (核心已转储)

解决方案
将这段代码里面的10改为2

float score = scores[10].item().toFloat();

float score = scores[2].item().toFloat();
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值