- Version of Matlab you are using
- The full error message and stacks that are displayed (e.g. are there any line numbers?)
- If possible, attaching your mat file would be ideal or
- Code that reproduces the issue
After saving deep learning network, can not load it.
2 次查看(过去 30 天)
显示 更早的评论
I was trying to Use transfer learning of VGGish pre-trained model to classify music genres. I changed the input layer to [300 64 1], after training, I saved the model, and when i loaded it next time, i got this error information: While loading an object of class 'DAGNetwork': Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
1 个评论
Richard
2023-9-20
It is definitely not expected that you will ever see an error of this kind when loading any DAGNetwork model. If you can provide more details then we might be able to help diagnose the issue further:
Even partial code for reproduction can be helpful - for example did you start from a specific pretrained network from one of our add-ons? Do you have the exact code used for the transfer learning?
回答(1 个)
Milan Bansal
2023-9-20
Hi,
I understand that you are facing an error while loading the saved Deep Learning Model.
The mentioned error typically occurs when the size of the loaded model's layers does not match the expected size.
Ensure that the size of the loaded model's layers matches the size you specified when you trained the model. In this case, the input layer was changed to [300 64 1]. Follow the steps given below to ensure the correct dimensions.
- Check the architecture and layer sizes of the pre-trained VGG model.
- Modify the architecture to match the desired input size. This involves adjusting the size of the input layer and any subsequent layers as per its output size.
- Re-train and save the model.
- When loading the model, make sure to load the correct version that matches the modified architecture and the input size.
Refer to documentation link to learn about "DAG(Directed Acyclic Graph) Network".
Refer to the documentation link to learn more about Transfer Learning with a pretrained VGG Net.
Hope it helps!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Data Workflows 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!