躺不平的废柴 2022-10-09 20:58 采纳率: 75%
浏览 1164
已结题

遇到RuntimeError报错该怎么处理?

遇到报错:
line 57, in forward
input_data = input_data.permute(2, 1, 0)
RuntimeError: number of dims don't match in permute

报错部分代码:

    def forward(self, input_data):
        # input_data:         Point Cloud having shape input_shape.
        # output:            PointNet features (Batch x emb_dims)
        if self.input_shape == "bnc":
            num_points = input_data.shape[1]
            input_data = input_data.permute(0, 2, 1)          #报错地方
        else:
            num_points = input_data.shape[2]
        if input_data.shape[1] != 3:
            raise RuntimeError("shape of x must be of [Batch x 3 x NumInPoints]")

        output = input_data
        for idx, layer in enumerate(self.layers):
            output = layer(output)

        return output

查看了input_data的维数,得到torch.Size([1, 3]) 确实是三维的

读取数据部分代码

    if args.user_data:
        source_path = os.path.join(r'E:\bunny\data\bun000.ply')  # The source point cloud is a rotated and offset defect
        # source=s3.float()
        source_data = o3d.io.read_point_cloud(source_path)
        points1 = np.array(source_data.points)
        idx1 = np.arange(points1.shape[0])
        np.random.shuffle(idx1)
        source = points1[idx1[:args.num_points]]

        template_path = os.path.join(r'E:\bunny\data\bun045.ply')  # Template point cloud is complete
        # template=s5.float()
        template_data = o3d.io.read_point_cloud(template_path)
        points2 = np.array(template_data.points)
        idx2 = np.arange(points2.shape[0])
        np.random.shuffle(idx2)
        template = points2[idx2[:args.num_points]]
        testset = UserData(template=template, source=source, tpcc=None, igt=None)

source和template都是三维的(如下所示)
[ 0.0585 0.0808363 0.0858177]
[ 0.0465 0.0650293 0.0904855]
[-0.00725 0.126023 0.0352551]

if __name__ == '__main__':
    # Test the code.
    x = torch.rand((10,1024,3))

    pn = PointNet(use_bn=True)
    y = pn(x)
    print("Network Architecture: ")
    print(pn)
    print("Input Shape of PointNet: ", x.shape, "\nOutput Shape of PointNet: ", y.shape)

  • 写回答

1条回答 默认 最新

  • buysnow 2022-10-10 00:13
    关注

    超时错误,输入数据input_data的维度必须是三维,检查下数据

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月19日
  • 已采纳回答 10月11日
  • 修改了问题 10月11日
  • 修改了问题 10月11日
  • 展开全部

悬赏问题

  • ¥30 酬劳2w元求合作写文章
  • ¥15 在现有系统基础上增加功能
  • ¥15 远程桌面文档内容复制粘贴,格式会变化
  • ¥15 关于#java#的问题:找一份能快速看完mooc视频的代码
  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图