项目场景:

pycharm运行代码train.py出现

TypeError: init() got an unexpected keyword argument 'n_channels


问题描述:

if __name__ == "__main__":
    # 选择设备,有cuda用cuda,没有就用cpu
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    # 加载网络,图片单通道1,分类为1。
    net = unet(n_channels=1, n_classes=1)
   

解决方案:

if __name__ == "__main__":
    # 选择设备,有cuda用cuda,没有就用cpu
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
    # 加载网络,图片单通道1,分类为1。
    net = UNet(1,1)
  
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐