Skip to content

Commit ff35426

Browse files
authored
Improved error message when data implicitly have batch dimension
1 parent 72d22cf commit ff35426

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ def count_cases(foo, ishape, oshape):
256256
return x.shape[0]
257257
else:
258258
# File has a single case
259+
"""
259260
if x.shape != ishape:
260261
# Shapes don't match
261262
raise ValueError("This file has improperly shaped input data:\n"+\
@@ -270,6 +271,15 @@ def count_cases(foo, ishape, oshape):
270271
"have the same number of cases:\n" + foo +\
271272
"\nInput shape: "+str(x.shape)+
272273
"\nOutput shape: "+str(y.shape))
274+
"""
275+
raise ValueError("It appears as if each data file has a single case, but " +\
276+
"there is no explicit batch dimension to indicate that. " +\
277+
"Reshape your data to have a batch dimension at the " +\
278+
"zero-th axis and try again.\n" +\
279+
"Expected input shape: (Nbatch," + str(ishape).replace('(', '') + '\n' +\
280+
"Received input shape: " + str(x.shape) + '\n' +\
281+
"Expected output shape: (Nbatch," + str(oshape).replace('(', '') + '\n' +\
282+
"Received output shape: " + str(y.shape) + '\n')
273283

274284

275285
def data_set_size(foos, ishape, oshape, ncores=1):

0 commit comments

Comments
 (0)