Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcnn_pool5_to_fcX problem #64

Open
empty16 opened this issue Nov 18, 2015 · 5 comments
Open

rcnn_pool5_to_fcX problem #64

empty16 opened this issue Nov 18, 2015 · 5 comments

Comments

@empty16
Copy link

empty16 commented Nov 18, 2015

Hi everyone,
I installed RCNN and trained R-CNN models on PASCAL VOC 07 datasets, when I use the command test_results = rcnn_exp_train_and_test() to get a trained model (I strictly followed every step in rcnn at github), unfortunately I cannot get the right answer, the error messages are as follows:

Error using  * 
Inputs must be 2-D, or at least one input must be scalar.
To compute elementwise TIMES, use TIMES (.*) instead.

Error in rcnn_pool5_to_fcX (line 21)
      feat = max(0, bsxfun(@plus, feat*rcnn_model.cnn.layers(i).weights{1}, ...

Error in rcnn_feature_stats (line 39)
    X = rcnn_pool5_to_fcX(X, layer, rcnn_model);

Error in rcnn_train (line 80)
opts.feat_norm_mean = rcnn_feature_stats(imdb, opts.layer, rcnn_model);

Error in rcnn_exp_train_and_test (line 19)
[rcnn_model, rcnn_k_fold_model] = ... 

Where did I go wrong? I hope someone can give a explanation of the fuction rcnn_pool5_to_fcX or help me figure out this problem, so I can get this code into my own research.
Thank you!

@empty16
Copy link
Author

empty16 commented Nov 19, 2015

I have got the solution. In Matlab R2014a, I use the squeeze and reshape function in the rcnn_pool5_to_fcX file, and finally I got an output as described in the paper.

@mahatmawoo
Copy link

Hi @empty16 ,

I'm also facing a similar issue on Matlab R2014b, just like you did.

The output :

Error using *
Inner matrix dimensions must agree.

Error in rcnn_pool5_to_fcX (line 30)
feat = max(0, bsxfun(@plus, feat*rcnn_model.cnn.layers(i).weights{1}, ...

Error in rcnn_feature_stats (line 42)
X = rcnn_pool5_to_fcX(X, layer, rcnn_model);

Error in rcnn_train_v2 (line 78)
opts.feat_norm_mean = rcnn_feature_stats(imdb, opts.layer, rcnn_model);

Error in rcnn_exp_train_and_test_v2 (line 19)
[rcnn_model, rcnn_k_fold_model] = ...

My interpretation of the problem:
After checking the size of feat = { 256 x 36 } and rcnn_model.cnn.layers(i).weights{1} ={ 9216 x 4096}, I conclude that 9216 must be reshaped into 36 for the matrix multiplication.

Proposed solution:
I'm thinking of applying the following reshaping in rcnn_pool5_to_fcX :

test_var=reshape(rcnn_model.cnn.layers(i).weights{1}, 36,[]);
feat = max(0, bsxfun(@plus, feat*test_var, ...
rcnn_model.cnn.layers(i).weights{2}'));

Question:
Is this where and how you performed the squeeze and reshape function?

Thank you in advance!

@mahatmawoo
Copy link

After applying

test_var=reshape(rcnn_model.cnn.layers(i).weights{1}, 36,[]);
feat = max(0, bsxfun(@plus, feat*test_var, ...
rcnn_model.cnn.layers(i).weights{2}'));

I got the following output:

Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.

Error in rcnn_pool5_to_fcX (line 31)
feat = max(0, bsxfun(@plus, feat*test_var, ...

Error in rcnn_feature_stats (line 42)
X = rcnn_pool5_to_fcX(X, layer, rcnn_model);

Error in rcnn_train_v2 (line 78)
opts.feat_norm_mean = rcnn_feature_stats(imdb, opts.layer, rcnn_model);

Error in rcnn_exp_train_and_test_v2 (line 19)
[rcnn_model, rcnn_k_fold_model] = ...

My interpretation of the problem:
The size of the test_var {36 X 1048576} is different from size of rcnn_model.cnn.layers(i).weights{2} { 4096 x 1}

Proposed solution:
Applied squeeze to test_var.

test_var=squeeze(test_var);

And the output gave me the same error:

Error using bsxfun
Non-singleton dimensions of the two input arrays must match each other.

Error in rcnn_pool5_to_fcX (line 33)
feat = max(0, bsxfun(@plus, feat*test_var, ...

My interpretation of the problem:
The size of the test_var before squeeze {36 X 1048576} and after squeeze {36 X 1048576} remains the same.

I'm not sure how to proceed.
Please feel free to share how you solve your issue. Thank you!

@empty16
Copy link
Author

empty16 commented Dec 8, 2015

Hi @mahatmawoo ,sorry,I got this message today.
Here is the solution in my rcnn_pool5_to_fcX.m file
feat = max(0, bsxfun(@plus, feat*squeeze(rcnn_model.cnn.layers(i).weights{1}), ... reshape(rcnn_model.cnn.layers(i).weights{2},... size(rcnn_model.cnn.layers(i).weights{2},3),... size(rcnn_model.cnn.layers(i).weights{2},4))));
because the dims of feat and weight are different ,so I changed the weights dim.
Hope this can help you.

@mahatmawoo
Copy link

Hi @empty16 , thanks again for your reply.
I'll have a look at your solution soon.
It may help solve my issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants