mirror of https://github.com/davisking/dlib.git
Fixed the serialization code for the kkmeans object so that it actually works.
--HG-- extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402481
This commit is contained in:
parent
f311e46d91
commit
de24dbb0ff
|
@ -138,14 +138,27 @@ namespace dlib
|
|||
|
||||
friend void serialize(const kkmeans& item, std::ostream& out)
|
||||
{
|
||||
serialize(item.centers, out);
|
||||
serialize(item.centers.size(),out);
|
||||
for (unsigned long i = 0; i < item.centers.size(); ++i)
|
||||
{
|
||||
serialize(*item.centers[i], out);
|
||||
}
|
||||
serialize(item.kc, out);
|
||||
serialize(item.assignments, out);
|
||||
}
|
||||
|
||||
friend void deserialize(kkmeans& item, std::istream& in)
|
||||
{
|
||||
deserialize(item.centers, in);
|
||||
unsigned long num;
|
||||
deserialize(num, in);
|
||||
item.centers.expand(num);
|
||||
for (unsigned long i = 0; i < item.centers.size(); ++i)
|
||||
{
|
||||
scoped_ptr<kcentroid<kernel_type> > temp(new kcentroid<kernel_type>(kernel_type()));
|
||||
deserialize(*temp, in);
|
||||
item.centers[i].swap(temp);
|
||||
}
|
||||
|
||||
deserialize(item.kc, in);
|
||||
deserialize(item.assignments, in);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue