Skip to content

Fail to compose a single predictive model #9

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

Open
lachioma opened this issue Dec 13, 2022 · 1 comment
Open

Fail to compose a single predictive model #9

lachioma opened this issue Dec 13, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@lachioma
Copy link

lachioma commented Dec 13, 2022

Hi
Thank you very much for providing a Matlab implementation of the SLEAP inference!
I am trying to run the demo code on a centroid+topdown models that I trained on my data, but I get the following error:

>> modelNet = sleap.model.topdown.compose(centroidNet, topdownNet, inputScale, bboxSize, minThreshold, centroidConfig, topdownConfig);
Error using  == 
Matrix dimensions must agree.

Error in sleap.model.topdown.compose (line 36)
sameNames = tdNames==centroidNames;

This error clearly occurs because the centroid and topdown models have a different number of layers.

Thank you for any help!
-alessandro

@talmo talmo added the bug Something isn't working label Jan 5, 2023
@talmo
Copy link
Contributor

talmo commented Jan 5, 2023

Hi @lachioma,

Thanks for reporting this! This seems like a bug to me. Specifically, this part of the compose function attempts to deal with having layer names that are the same between the centroid and centered instance models:

% Since array layer names for both centroid and topdown models have
% commonalities, create unique names for topdown model inorder to combine
% all into a single model
centroidNames = arrayfun(@(x) string(x.Name), net.Layers);
tdNames = arrayfun(@(x) string(x.Name), topdownNet.Layers);
sameNames = tdNames==centroidNames;
newtdNames = tdNames;
newtdNames(sameNames) = matlab.lang.makeUniqueStrings(centroidNames(sameNames), tdNames(sameNames));
larrayTd = topdownNet.Layers;

This is necessary MATLAB can't have layers with the same name within the same DAGNetwork (while this is handled via scoping in TensorFlow). The names are the same because we use the same general architecture (UNet) for the backbone, though they might be configured differently, resulting in different variants which have different numbers of layers.

I think the fix here will be to change up the logic in that snippet above to use ismember or string contains or intersect to find the repeated layer names and only rename those.

Maybe an even easier solution that mimics what TensorFlow does is to add a scoping prefix to all layers from each model type.

We'll work on a fix and report back here when we have a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants