# Batch-size-agnostic ReshapeVertex?

**URL:** <https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816>\
**Category:** DL4J\
**Created:** [August 25, 2020, 1:30pm UTC](https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816 "2020-08-25T13:30:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![novog](https://avatars.discourse-cdn.com/v4/letter/n/8e7dd6/32.png) [@novog](https://community.konduit.ai/u/novog)\
**Post date:** [August 25, 2020, 1:30pm UTC](https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816/1 "2020-08-25T13:30:57Z")

</div>

I have a question about `ReshapeVertex`. Many layer types can be used with inputs of any batch size. I can’t find much in the way of example code using `ReshapeVertex`, but it seems to require that the actual batch size is included in the output dimensions. For example, if individual inputs are vectors of length 100 and I want to transform them to 10x10 matrices, I can’t use `ReshapeVertex(10, 10)`, but rather `ReshapeVertex(n, 10, 10)`, where `n` is the batch size.

Is it possible to employ `ReshapeVertex` without committing the network to a particular batch size? Alternatively, is there another layer or vertex type that can be used to reshape its input without knowing the batch size ahead of time? Thanks!

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [August 26, 2020, 12:46pm UTC](https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816/2 "2020-08-26T12:46:01Z")

</div>

I don’t see any reason why we couldn’t add this. Mind filing an issue? htps://github.com/eclipse/deeplearning4j/issues?

If you want, you could also do a PR:

> <https://github.com/eclipse/deeplearning4j/blob/88d3c4867fb87ec760b445c6b9459ecf353cec47/deeplearning4j/deeplearning4j-nn/src/main/java/org/deeplearning4j/nn/graph/vertex/impl/ReshapeVertex.java#L41>

Unfortunately, there’s not really a workaround unless you want to just do a custom vertex yourself for your use case:

> **[deeplearning4j-examples/dl4j-examples/src/main/java/org/deeplearning4j/examples/...](https://github.com/eclipse/deeplearning4j-examples/tree/9e971fdb782249873786a960f248247dd28650fa/dl4j-examples/src/main/java/org/deeplearning4j/examples/advanced/features/customizingdl4j/layers)**
>
> 9e971fdb782249873786a960f248247dd28650fa/dl4j-examples/src/main/java/org/deeplearning4j/examples/advanced/features/customizingdl4j/layers

---

<div class="post-metadata">

**Author:** ![cagneymoreau](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/cagneymoreau/32/296_2.png) [@cagneymoreau](https://community.konduit.ai/u/cagneymoreau)\
**Post date:** [August 27, 2020, 1:00am UTC](https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816/3 "2020-08-27T01:00:02Z")

</div>

maybe im way off but isnt a 1x10x10 the same as a 10x10?

---

<div class="post-metadata">

**Author:** ![agibsonccc](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/agibsonccc/32/697_2.png) [@agibsonccc](https://community.konduit.ai/u/agibsonccc)\
**Post date:** [August 28, 2020, 11:26am UTC](https://community.konduit.ai/t/batch-size-agnostic-reshapevertex/816/4 "2020-08-28T11:26:41Z")

</div>

Kind of, the issue is right now it only reshapes to the exact shape. There’s no built in functionality for saying “this subset of dimensions + tolerance for a changing number on the first axis”
