# Machine Learning in Elixir: Error in Chapter 9, identifying cats and dogs again

**URL:** <https://forum.devtalk.com/t/machine-learning-in-elixir-error-in-chapter-9-identifying-cats-and-dogs-again/128336>\
**Category:** PragProg Customers\
**Tags:** book-machine-learning-in-elixir, question\
**Created:** [13 October 2023 14:22 UTC](https://forum.devtalk.com/t/machine-learning-in-elixir-error-in-chapter-9-identifying-cats-and-dogs-again/128336 "2023-10-13T14:22:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![joshprintsimple](https://forum.devtalk.com/letter_avatar_proxy/v4/letter/j/41988e/32.png) [@joshprintsimple](https://forum.devtalk.com/u/joshprintsimple)\
**Post date:** [25 October 2023 09:25 UTC](https://forum.devtalk.com/t/machine-learning-in-elixir-error-in-chapter-9-identifying-cats-and-dogs-again/128336/2 "2023-10-25T09:25:09Z")

</div>

@seanmor5

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:

```auto
{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)

```

---

_[View the full topic](https://forum.devtalk.com/t/machine-learning-in-elixir-error-in-chapter-9-identifying-cats-and-dogs-again/128336)._
