【问题标题】:how can i fix pytorch predict problem with deep learning我如何解决深度学习的pytorch预测问题
【发布时间】:2020-08-17 15:55:50
【问题描述】:

给定groups=1,大小为[48, 3, 3, 3] 的权重,预期输入[5, 128, 129, 4] 有3 个通道,但实际上有128 个通道。

这是我的代码:

    **model_ft.eval()
    for image in test_loader:
        image = image.cuda()
        output = model_ft(image)
        output = output.cpu().detach().numpy()
        for i, (e, n) in enumerate(list(zip(output, name))):
            sub.loc[sub['id_code'] == n.split('/')[-1].split('.')[0], 'diagnosis'] = le.inverse_transform([np.argmax(e)])
            
    sub.to_csv('submission.csv', index=False)**
    
    print(X_test.shape)
    (3071, 128, 128, 3)
    from torch.utils.data import DataLoader
    test_loader = DataLoader(X_test, batch_size=5, shuffle=True)
    print(train_data)

我不知道如何解决这个问题来预测我的竞争对手

【问题讨论】:

    标签: python class pytorch prediction efficientnet


    【解决方案1】:

    我假设

    print(X_test.shape)
    (3071, 128, 128, 3)
    

    您的意思是测试数据有 3071 个样本,每个样本具有 128x128 像素和 3 个颜色通道。 另外我假设您使用的模型不会转置输入,因此卷积层期望默认布局为形状 (N, C, H, W) 但您将数据提供为 (N, H, W , C)。

    解决方案:在将其交给模型之前尝试image.transpose_(1, 3)image = image.cuda().transpose(1, 3)

    【讨论】:

      猜你喜欢
      • 2018-09-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多