The length of the val_paths has to be divisible by the batch number so that the tensors come out the right shape.
You can just add this line
val_paths = Enum.take(val_paths, 224)
after setting the val_paths. I also removed the Enum.take line at the end because the length of the train_paths is 24000 and that is also divisible by a batch size of 32.
so that cell would look like this now:
{test_paths, train_paths} =
Path.wildcard("train/*.jpg")
|> Enum.shuffle()
|> Enum.split(1000)
{test_paths, val_paths} = test_paths |> Enum.split(750)
val_paths = Enum.take(val_paths, 224)
batch_size = 32
target_height = 160
target_width = 160
train_pipeline =
CatsAndDogs.pipeline_with_augmentations(
train_paths,
batch_size,
target_height,
target_width
)
val_pipeline =
CatsAndDogs.pipeline(
val_paths,
batch_size,
target_height,
target_width
)
test_pipeline =
CatsAndDogs.pipeline(
test_paths,
batch_size,
target_height,
target_width
)
# Enum.take(train_pipeline, 1)