【发布时间】:2020-03-21 15:02:35
【问题描述】:
我正在尝试从here 实施空间变压器网络,我遇到了这个问题:
class STNLayer(torch.nn.Module):
def __init__(self, input_size):
super(STNLayer, self).__init__()
self.input_size = input_size
self.localization = nn.Sequential(
nn.Conv2d(self.input_size, 8, kernel_size = 7),
nn.MaxPool2d(2, stride = 2),
nn.ReLU(True),
nn.Conv2d(8, 10, kernel_size = 5),
nn.MaxPool2d(2, stride = 2),
nn.ReLU(True)
)
self.fc_loc = nn.Sequential(
nn.Linear(10 * 12 * 12, 32),
nn.ReLU(True),
#nn.BatchNorm1d(32),
nn.Linear(32, 3*2)
)
# Initialize weights to identity transformation
self.fc_loc[2].weight.data.zero_()
self.fc_loc[2].bias.data = torch.cuda.FloatTensor([1,0,0,0,1,0])
线
self.fc_loc[2].bias.data = torch.cuda.FloatTensor([1,0,0,0,1,0])
给出错误:
*** AttributeError: module 'torch' has no attribute 'float'
我该如何解决这个问题?
【问题讨论】:
-
请始终发布完整的错误回溯。你用的是什么pytorch版本?