报错:

raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'DataParallel' object has no attribute 'XXX'

原因: 多卡训练使用DataParallel,model中的方法名添加了module前缀

解决: 方法名中添加module前缀,将model.XXX改为model.module.XXX,例如:

model = DataParallel(model)
model.module.encoder()
model.module.decoder()

Logo

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

更多推荐