syfafterzy / SVDNet-for-Pedestrian-Retrieval

Code for https://arxiv.org/abs/1703.05693
138 stars 47 forks source link

维度不匹配 #10

Open wjzh1 opened 6 years ago

wjzh1 commented 6 years ago

请问一下我用resnet18网络训练自己的数据收敛,然后把模型使用SVD的方法,为啥出现维度不匹配的问题,怎么解决

ghost commented 6 years ago

@wjzh1 检查一下https://github.com/syfafterzy/SVDNet-for-Pedestrian-Retrieval/blob/439ae0e086304cc8e38c8112b2a96e1a8ebdf647/matlab/SVDNet/change_resnet_W.m#L1 deploy renset的时候你得prototext和model是对应的吗?按照给了resnet50的案例照着理一遍,就可以训练出来的。仔细一点。

wjzh1 commented 6 years ago

resnet50是可以的,但是18我加了fc输出是1024维度的,就会出现我之前那问题

------------------ 原始邮件 ------------------ 发件人: "John"notifications@github.com; 发送时间: 2018年4月16日(星期一) 下午4:58 收件人: "syfafterzy/SVDNet-for-Pedestrian-Retrieval"SVDNet-for-Pedestrian-Retrieval@noreply.github.com; 抄送: "beyond"1678824369@qq.com; "Mention"mention@noreply.github.com; 主题: Re: [syfafterzy/SVDNet-for-Pedestrian-Retrieval] 维度不匹配 (#10)

@wjzh1 检查一下https://github.com/syfafterzy/SVDNet-for-Pedestrian-Retrieval/blob/439ae0e086304cc8e38c8112b2a96e1a8ebdf647/matlab/SVDNet/change_resnet_W.m#L1 deploy renset的时候你得prototext和model是对应的吗?按照给了resnet50的案例照着理一遍,就可以训练出来的。仔细一点。

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

那你的deploy.prototxt,也加了fc了吗,对应上了吗。另外你的维度不匹配是啥不匹配,具体一点

wjzh1 commented 6 years ago

加了的,对应上了,W=U(:,1:Dim)*S(1:Dim,:);这个地方出错,矩阵的维度不对

------------------ 原始邮件 ------------------ 发件人: "John"notifications@github.com; 发送时间: 2018年4月16日(星期一) 下午5:13 收件人: "syfafterzy/SVDNet-for-Pedestrian-Retrieval"SVDNet-for-Pedestrian-Retrieval@noreply.github.com; 抄送: "beyond"1678824369@qq.com; "Mention"mention@noreply.github.com; 主题: Re: [syfafterzy/SVDNet-for-Pedestrian-Retrieval] 维度不匹配 (#10)

那你的deploy.prototxt,也加了fc了吗,对应上了吗。另外你的维度不匹配是啥不匹配,具体一点

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

你自己检查一下啊,对W做SVD分解,怎么会维度不一致,你一行一行看一下啊。[U,S,V]=svd(tmp);W=U(:,1:Dim)*S(1:Dim,:);

wjzh1 commented 6 years ago

resnet50加的fc层前面是2048维,resnet18前面是512维,所有维度有问题,不知道咋办

------------------ 原始邮件 ------------------ 发件人: "John"notifications@github.com; 发送时间: 2018年4月16日(星期一) 晚上6:43 收件人: "syfafterzy/SVDNet-for-Pedestrian-Retrieval"SVDNet-for-Pedestrian-Retrieval@noreply.github.com; 抄送: "beyond"1678824369@qq.com; "Mention"mention@noreply.github.com; 主题: Re: [syfafterzy/SVDNet-for-Pedestrian-Retrieval] 维度不匹配 (#10)

你自己检查一下啊,对W做SVD分解,怎么会维度不一致,你一行一行看一下啊。[U,S,V]=svd(tmp);W=U(:,1:Dim)*S(1:Dim,:);

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

Okay, W is 512 x 1024. After SVD, we get U, S, and V. Note that U is 512 x512, S is 512x1024, and V is 1024 X 1024. Yet, the dim in code is defined as "Dim=size(W, 2)", and dim is 2048. That is the reason causes the dimension is unmatchable.

Based on above, I think we can change the dim from 2048 to 512.

What your opinion?

wjzh1 commented 6 years ago

你的那个Dim是1024吧,我也把我的改成512了,还是出错。

------------------ 原始邮件 ------------------ 发件人: "John"notifications@github.com; 发送时间: 2018年4月17日(星期二) 中午1:51 收件人: "syfafterzy/SVDNet-for-Pedestrian-Retrieval"SVDNet-for-Pedestrian-Retrieval@noreply.github.com; 抄送: "beyond"1678824369@qq.com; "Mention"mention@noreply.github.com; 主题: Re: [syfafterzy/SVDNet-for-Pedestrian-Retrieval] 维度不匹配 (#10)

Okay, W is 512 x 1024. After SVD, we get U, S, and V. Note that U is 512 x512, S is 512x1024, and V is 1024 X 1024. Yet, the dim is code is defined as "Dim=size(W, 2)", and dim is 2048. That is the reason causes the dimension is unmatchable.

Based on above, I think we can change the dim from 2048 to 512.

What your opinion?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

ghost commented 6 years ago

你在程序里面看一下你的W多少维度?

你直接修改成这样:[U,S,V]=svd(tmp);W=U*S;