Skip to content

第十章,demo.ipynb #17

Closed
Closed
@cryer

Description

有一个可能是个人问题。。。我的resnet50去除FC层输出尺寸竟然是(1,8192)不是(1,2048),百思不得其解,打印出内容也不是0,是有值的。我换了种写法,结果还是差不多,尺寸变成了(1,2048,2,2),然后调用(:,:,0,0)的输出和标准答案是一样的,(:,:,0,1),(:,:,1,1),(:,:,1,0)都有所偏差。修改后的代码如下:

resnet50 = tv.models.resnet50(pretrained = True).eval()
# del resnet50.fc
modules = list(resnet50.children())[:-1]
resnet50 = t.nn.Sequential(*modules)
# resnet50.fc = lambda x:x
if opt.use_gpu:
    resnet50.cuda() 
    img = img.cuda()
img_feats = resnet50(Variable(img,volatile=True))
img_feats = img_feats[:,:,0,0]
print(img_feats.data.squeeze(0).size())
print(img_feats)

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions