打电话
triplet_loss = nn.TripletMarginLoss()
结果是:
AttributeError: module 'torch.nn' has no attribute 'TripletMarginLoss'
即使
import torch.nn as nn
添加的相关 PR 引入了 TripletMarginLoss:#1165
现在的解决方法是直接使用F.triplet_margin_loss
,其中F
是import torch.nn.functional as F
。
另一种解决方法是添加from torch.nn.modules.loss import TripletMarginLoss
。
固定在主人。 将在下一个版本中。
嗨,当我打电话给m = nn.Upsample(scale_factor=2, mode='bilinear')
时会发生类似的事情
AttributeError: 'module' 对象没有属性 'Upsample'
但我可以成功调用nn.UpsamplingBilinear2d
。
另外,有没有计划实施Cubic Upsample
~
最有用的评论
嗨,当我打电话给
m = nn.Upsample(scale_factor=2, mode='bilinear')
时会发生类似的事情AttributeError: 'module' 对象没有属性 'Upsample'
但我可以成功调用
nn.UpsamplingBilinear2d
。另外,有没有计划实施
Cubic Upsample
~