Fix deserialize logic in loss_multibinary_log (#2547)

This commit is contained in:
Adrià Arrufat 2022-03-23 20:35:56 +09:00 committed by GitHub
parent 1b7053fe9d
commit 3b518f40ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -877,11 +877,20 @@ namespace dlib
{
std::string version;
deserialize(version, in);
if (version != "loss_multibinary_log_" || version != "loss_multibinary_log_2")
throw serialization_error("Unexpected version found while deserializing dlib::loss_multibinary_log_.");
if (version == "loss_multibinary_log_2")
if (version == "loss_multibinary_log_")
{
item.gamma = 0;
return;
}
else if (version == "loss_multibinary_log_2")
{
deserialize(item.gamma, in);
}
else
{
throw serialization_error("Unexpected version found while deserializing dlib::loss_multibinary_log_.");
}
}
friend std::ostream& operator<<(std::ostream& out, const loss_multibinary_log_& item)
{