Add error message for mismatched tensor sizes in dnn_trainer (#2165)

This commit is contained in:
Adrià Arrufat 2020-09-08 20:16:15 +09:00 committed by GitHub
parent 40c3e48818
commit 77e6255fdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -764,7 +764,12 @@ namespace dlib
{
std::vector<tensor*> temp(all_tensors.size());
for (size_t j = 0; j < all_tensors.size(); ++j)
{
temp[j] = all_tensors[j][i];
DLIB_CASSERT(temp[0]->size() == temp[j]->size(),
"Make sure you don't modify the network structure "
"or number of parameters after constructing the trainer.");
}
// ignore layers that don't have parameters
if (temp[0]->size() != 0)
averagers[i].set(temp);