machine-learning-book
machine-learning-book copied to clipboard
Chapter 15: TypeError
The test dataset is a DataPipe, and therefore does not have a length, which results in the following error in the evaluate function:
return total_acc/len(dataloader.dataset), total_loss/len(dataloader.dataset)
TypeError: MapperIterDataPipe instance doesn't have valid length
One way to fix this is to convert that to a list, before applying the len()
function:
return total_acc/len(list(dataloader.dataset)), total_loss/len(list(dataloader.dataset))