Error loading TreeBagger from .MAT file in deployed app.

조회 수: 2 (최근 30일)
Geoff
Geoff 2012년 2월 2일
댓글: zhiqiang gao 2018년 6월 8일
Hiya =)
I've been browsing the forums looking for information on this... When run in MatLab my app works fine. But when it is deployed, I get this message:
Warning: Variable 'model' originally saved as a TreeBagger cannot be instantiated as an object and will be read in as a uint32.
I have a deployed app that trains models and stores them out using save() with '-struct' semantics. Another deployed app loads and uses these models regularly.
Note that my TreeBagger is actually a field within the struct (maybe this is significant):
model.meta % a whole bunch of info
model.model % the TreeBagger object
I have come across the following article that may explain the behaviour. It discusses saving (but not loading?) of user-defined objects:
This is where I am confused. The TreeBagger object is not really user-defined as such. It's part of a rather expensive toolbox, and would presumably define its own saveobj and loadobj methods if it needed to...
Do I need to follow the linked article and hack the TreeBagger class, or is there a simple solution?
Thanks in advance!
-g-
  댓글 수: 2
Geoff
Geoff 2012년 2월 2일
Just need to bump this question again, as I'm really stuck and there's an awful lot at stake for this project! I am flabbergasted at the things that seem to go wrong when you deploy an application! It's almost like starting the development again.
I tried copying the TreeBagger class definition m-file into my deployment directory (it was a long shot), but no luck.
Any suggestions? =(
Walter Roberson
Walter Roberson 2012년 2월 2일
You should probably open a support case.

댓글을 달려면 로그인하십시오.

채택된 답변

owr
owr 2012년 2월 2일
  댓글 수: 1
Geoff
Geoff 2012년 2월 2일
Thank you so much! I spent ages trying to find this information but my searches never turned up anything useful.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Geoff
Geoff 2012년 2월 2일
Just for completeness, I'll post the solution from owr's linked article....
The class definition must be imported by including a pragma in my function that calls load(). As follows:
function [model] = loadmodel( filename )
%#function TreeBagger
model = load( filename, '-mat' );
end
Yaay!!!
Cheers =)

카테고리

Help CenterFile Exchange에서 Classification Ensembles에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by